guolei19850528 / laravel-workwx
A Work Weixin Laravel Library Developed By Guolei
v1.0.2
2024-12-03 07:53 UTC
Requires
- php: 8.*
- illuminate/support: 7.*||8.*||9.*||10.*||11.*
README
A Work Weixin Laravel Library Developed By Guolei
Installation
composer require guolei19850528/laravel-workwx
Example
Webhook
use Guolei19850528\Laravel\Workwx\Webhook; $webhook = new Webhook('key','base url',['mentioned list'],['mentioned mobile list']); $state=$webhook->send( $webhook->sendTextFormatter( 'test message' ) ); if ($state){ print_r('success'); }else{ print_r('failed'); } $mediaId = $webhook->uploadMedia( [ 'name' => 'name', 'filename' => 'filename', 'contents' => fopen('your file path', 'rb'), ], 'file' ); if (\str($mediaId)->isNotEmpty()) { $state=$webhook->send($webhook->sendFileFormatter($mediaId)); if ($state){ print_r('success'); }else{ print_r('failed'); } }
Server
use Guolei19850528\Laravel\Workwx\Server; $server=new Server( 'your corpid', 'your corpsecret', 'your agentid' ); $state=$server->tokenWithCache()->messageSend([ 'touser'=>'', 'msgtype'=>'text', 'agentid'=>$server->getAgentid(), 'text'=>[ 'content'=>'test message' ] ]); if($state){ print_r('successful'); }