钉钉发送信息脚本

每次运行都实时查询,中间数据可以放在数据库或文本中提高信息发送速度

php dingtalk.php 电话号码  “信息内容”

'$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);
?>


你可能感兴趣的:(网络与系统管理,杂项)