关于钉钉:浙政钉发送消息


浙政钉发送音讯文档:https://openplatform-portal.dg-work.cn/#/docs?apiType=serverapi&docKey=2674961

1:引入sdk:https://openplatform-portal.dg-work.cn/portal/#/helpdoc?docKey=gjyzy&slug=st5ct2

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;//发送失败

如上咱们就能够实现音讯告诉性能了

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理