PHP code example of youduphp / laravel-youdu

1. Go to this page and download the library: Download youduphp/laravel-youdu library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

youduphp / laravel-youdu example snippets


$app->register(Illuminate\Notifications\NotificationServiceProvider::class); // must before YouduServiceProvider
$app->register(YouduPhp\LaravelYoudu\YouduServiceProvider::class);

use YouduPhp\LaravelYoudu\Facades\Youdu;

Youdu::message()->send('user1|user2', 'dept1|dept2', 'test'); // send to user and dept
Youdu::message()->sendToUser('user1|user2', 'test'); // send to user
Youdu::message()->sendToDept('dept1|dept2', 'test'); // send to dept

use YouduPhp\LaravelYoudu\Facades\Youdu;

Youdu::message()->send('user1|user2', 'dept1|dept2',new Text('test'));
Youdu::message()->sendToUser('user1|user2', new Image($mediaId)); // $mediaId 通过 Youdu::media()->upload() 接口获得
Youdu::message()->sendToDept('dept1|dept2', new File($mediaId)); // $mediaId 通过 Youdu::media()->upload() 接口获得
// ...

use YouduPhp\LaravelYoudu\Facades\Youdu;

$mediaId = Youdu::media()->upload($file, $fileType); // $fileType image代表图片、file代表普通文件、voice代表语音、video代表视频

use YouduPhp\LaravelYoudu\Facades\Youdu;

Youdu::media()->download($mediaId, $savePath);
bash
php artisan vendor:publish --provider="YouduPhp\\LaravelYoudu\\YouduServiceProvider"
bash
cp vendor/youduphp/laravel-youdu/config/youdu.php config