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

54次阅读

共计 1175 个字符,预计需要花费 3 分钟才能阅读完成。


浙政钉发送音讯文档: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;// 发送失败 

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

正文完
 0