youduphp / laravel-youdu
The youdu component for laravel
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- php: >=8.1
- illuminate/contracts: ^10.0|^11.0
- illuminate/notifications: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
- youduphp/youdu: ^1.1.0
Requires (Dev)
- huangdijia/php-coding-standard: ^1.1
- orchestra/testbench: ^8.0|^9.0
- phpstan/phpstan: ^1.0
This package is auto-updated.
Last update: 2024-12-11 03:52:35 UTC
README
Installation
Laravel
composer
composer require "youduphp/laravel-youdu:^2.0"
publish
php artisan vendor:publish --provider="YouduPhp\\LaravelYoudu\\YouduServiceProvider"
Lumen
add YouduServiceProvider
to bootstrap/app.php
$app->register(Illuminate\Notifications\NotificationServiceProvider::class); // must before YouduServiceProvider $app->register(YouduPhp\LaravelYoudu\YouduServiceProvider::class);
copy youdu.php
to config/
cp vendor/youduphp/laravel-youdu/config/youdu.php config
Usage
Send text message
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
Send other type
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() 接口获得 // ...
Message types
Upload file
use YouduPhp\LaravelYoudu\Facades\Youdu; $mediaId = Youdu::media()->upload($file, $fileType); // $fileType image代表图片、file代表普通文件、voice代表语音、video代表视频
Download file
use YouduPhp\LaravelYoudu\Facades\Youdu; Youdu::media()->download($mediaId, $savePath);