1. Go to this page and download the library: Download fangchaogang/kam-php 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/ */
fangchaogang / kam-php example snippets
use Kam\Request\Base\SendLinkMsgRequest;
use Kam\Request\Base\SendShareMusicRequest;
use Kam\Request\Base\SendTextMsgRequest;
$robotWxId = 'wxid_lmqw4m0uznw522';
try {
//发送消息
$request = new SendTextMsgRequest();
$request->setRobotWxId($robotWxId);
$request->setToWxId('fcg_520');
$request->setMsg('你好');
$request->request();
//发送分享连接
$request = new SendLinkMsgRequest();
$request->setRobotWxId($robotWxId);
$request->setToWxId('fcg_520');
$request->setTargetUrl('http://www.baidu.com');
$request->setPicUrl('http://dgj-dev.kzmall.cc/statics/old/css/base/img/cooperation.png?ver=2.20.94');
$request->setTitle('分享');
$request->setText('我分享了地址');
$request->request();
//发送音乐
$request = new SendShareMusicRequest();
$request->setRobotWxId($robotWxId);
$request->setToWxId('fcg_520');
$request->setName('十年');
//...其他请参考文档
} catch (\Exception $e) {
//接口逻辑处理失败(明确返回的失败)
//错误码:$e->getCode()
//错误信息:$e->getMessage()
}