浙政钉发送消息
Posted huaweichenai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了浙政钉发送消息相关的知识,希望对你有一定的参考价值。
浙政钉发送消息文档:https://openplatform-portal.d...
1:引入sdk:https://openplatform-portal.d...
2:发送消息实现(这里我只实现文本消息,具体其他形式消息,可查看文档实现)
//接收消息
$msg = [
\'msgtype\' => \'text\',
\'text\' => [
\'content\' => \'测试消息\'
]
];
try {
$executableClient = new ExecutableClient();
//Saas环境域名为:https://openplatform.dg-work.cn,浙政钉环境域名为:https://openplatform-pro.ding.zj.gov.cn
$executableClient->setDomain(\'域名\');
$executableClient->setAccessKey(\'应用App Key\');
$executableClient->setSecretKey(\'应用App Secret\');
$executableClient->setApiName(\'/chat/sendMsg\');
$executableClient->addParameter(\'msg\', json_encode($msg));//消息体(参考下文示例消息格式)
$executableClient->addParameter(\'senderId\', \'发送者用户id\');
$executableClient->addParameter(\'receiverId\', \'单聊接受者用户id(chatType为1时必填)\');
$executableClient->addParameter(\'tenantId\', \'租户id\');
$executableClient->addParameter(\'chatType\', 1);//发起的会话类型(1单聊、2群聊)
$result = $executableClient->epaasCurlGet(3);
} catch (\\Exception $e) {
$msg = "getFilterWords|err, code: ". $e->getCode() . "|message: ". $e->getMessage();
Yii::error($msg);
return $msg;
}
if (isset($result[\'success\']) && $result[\'success\'] == true) {
return true;//发送成功
}
return false;//发送失败
如上我们就可以实现消息通知功能了
以上是关于浙政钉发送消息的主要内容,如果未能解决你的问题,请参考以下文章