guolei9850528 / laravel-qywx-library
There is no license information available for the latest version (v1.0.0) of this package.
企业微信laravel类库
v1.0.0
2024-07-11 01:53 UTC
Requires
- php: ^8.0.2
- illuminate/support: 9.*
This package is auto-updated.
Last update: 2024-09-24 05:49:28 UTC
README
介绍
laravel 企业微信类库
群机器人Webhook 使用说明
use Guolei\Laravel\Qywx\Library\Webhook;
//@see https://developer.work.weixin.qq.com/document/path/91770
//实例化webhook
$webhook = new Webhook(
'https://qyapi.weixin.qq.com/cgi-bin/webhook/',
'群机器人key'
);
//发送
$state=$webhook->send(['数据'],['guzzle 选项'],'url');
//发送文本信息
$state=$webhook->sendText('内容',['@姓名'],['@手机号'],['guzzle 选项'],'url');
if ($state){
echo '发送成功';
}
//上传文件
$mediaId=$webhook->upload(['文件'],'类型 file or voice',['guzzle 选项'],'url');
if (\str($mediaId)->isNotEmpty()){
echo '上传成功';
}
//发送文件
$state=$webhook->sendFile('media id',['guzzle 选项'],'url');
if ($state){
echo '发送成功';
}
//发送声音文件
$state=$webhook->sendVoice('media id',['guzzle 选项'],'url');
if ($state){
echo '发送成功';
}
Server API 使用说明
//@see https://developer.work.weixin.qq.com/document/path/90664
$server = new Server(
'https://qyapi.weixin.qq.com',
'corpid',
'corpsecret',
'agentid'
);
$state=$server->accessToken()->messageSend(
[
'touser'=>'',
'msgtype'=>'text',
'agentid'=>$server->getAgentid(),
'text'=>[
'content'=>'test message'
]
]
);
if ($state){
print_r('成功')
}else{
print_r('失败')
}
$mediaId=$server->accessToken()->upload(...['your params']);
$mediaId=$server->accessToken()->uploadImg(...['your params']);