钉钉发送信息脚本
来源:互联网 发布:scilab 矩阵 编辑:程序博客网 时间:2024/04/28 21:56
每次运行都实时查询,中间数据可以放在数据库或文本中提高信息发送速度
php dingtalk.php 电话号码 “信息内容”
<?php//获取token$corpid="xxxxxxx";$corpsecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";$userlist=array();$url="https://oapi.dingtalk.com/gettoken?corpid=".$corpid."&corpsecret=".$corpsecret;$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, 0);$output=curl_exec($ch);curl_close($ch);$out_array = json_decode($output,true);$access_token = $out_array["access_token"];//获取电话与userid对应关系$url="https://oapi.dingtalk.com/department/list?access_token=".$access_token;$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, 0);$output=curl_exec($ch);$out_array = json_decode($output,true);//var_dump($out_array);foreach ($out_array["department"] as $DPID){ //echo $DPID["id"]; //echo "\n"; $url="https://oapi.dingtalk.com/user/list?access_token=".$access_token."&department_id=".$DPID["id"]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $output=curl_exec($ch); $out_array = json_decode($output,true); //var_dump($out_array); foreach ($out_array["userlist"] as $USR){ $userlist[$USR["mobile"]]=$USR["userid"]; //$tem_array('$USR["mobile"]'=>'$USR["userid"]'); //array_merge($userlist,$tmp_array]); }}var_dump($userlist);//发送消息$url="https://oapi.dingtalk.com/message/send?access_token=".$access_token;$post_array=array("touser" => $userlist[$argv[1]],"agentid" => "xxxxx", "msgtype" => "text", "text" => array("content" => $argv[2]));$post_string=json_encode($post_array);$ch = curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($post_string)) );$output = curl_exec($ch);curl_close($ch);print_r($output);?>
0 0
- 钉钉发送信息脚本
- 钉钉消息发送
- 钉钉接口发送消息失败
- Python实现钉钉发送报警消息
- 【广告项目】钉钉实现发送通知
- zabbix企业微信号、钉钉报警脚本
- 钉钉的API
- 钉钉打卡神器
- 钉钉机器人
- 钉钉自定义机器人
- 钉钉报警
- 钉钉定时打卡
- 钉钉子
- 钉钉的功能介绍
- 钉钉机器人自动提醒
- 钉钉消息推送教程
- 钉钉平台接入文档
- C# 钉钉系列目录
- python回归分析相关代码-散点图,回归,预测
- 1118. Birds in Forest (25) (并查集,注意顺序)
- 剑指offer经典编程(十)
- 关闭弹框层
- 设置radiobutton中drawable图片的大小,checkBox应该也可以
- 钉钉发送信息脚本
- HttpLoggingInterceptor的用法简介
- 进程间通讯(二)--管道
- symfony2 学习笔记
- nginx简单的操作
- 我认识的林家翘先生 转载
- Coredata数据库的增删改查
- 表单控件多文件上传
- echarts-设置折线样式和X轴和Y轴的分割线样式