docs/src/5.x/wework/kf.md
我们在企业微信 ”微信客服” 应用开启API接收消息的功能
将设置页面的 token 与 aes key 配置到 agents 下对应的应用内
注意: 需要使用“微信客服”secret所获取的accesstoken来调用
$config = [
'corp_id' => 'xxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxx',
// server config
'token' => 'xxxxxxxxx',
'aes_key' => 'xxxxxxxxxxxxxxxxxx',
//...
];
$app = Factory::work($config);
接着配置服务端与公众号的服务端用法一样:
请参考微信客服文档 https://open.work.weixin.qq.com/api/doc/90000/90135/94670
$app->server->push(function($message){
// $message['FromUserName'] // 消息来源
// $message['MsgType'] // 消息类型:event ....
return 'Hello easywechat.';
});
$response = $app->server->serve();
$response->send();
$response 为 Symfony\Component\HttpFoundation\Response 实例,根据你的框架情况来决定如何处理响应。
$app->kf_account->add(string $name, string $mediaId);
$app->kf_account->del(string $openKfId);
$app->kf_account->update(string $openKfId, string $name, string $mediaId);
$app->kf_account->list();
$app->kf_account->getAccountLink(string $openKfId, string $scene);
$app->kf_servicer->add(string $openKfId, array $userIds);
$app->kf_servicer->del(string $openKfId, array $userIds);
$app->kf_servicer->list(string $openKfId);
$app->kf_message->state(string $openKfId, string $externalUserId);
$app->kf_message->updateState(string $openKfId, string $externalUserId, int $serviceState, string $serviceUserId);
$app->kf_message->sync(string $cursor, string $token, int $limit);
$app->kf_message->send(array $params);
$app->kf_message->event(array $params);