钉钉自定义机器人PHP版如何接入
Re钉钉自定义机器人PHP版如何接入
用官方的样本,进行测试也是一样木有返回值,是不是环境问题
function request_by_curl($remote_server, $post_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $remote_server);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Content-Type: application/json;charset=utf-8'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$webhook = 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxx';
$message='我就是我, 是不一样的烟火';
$data = array ('msgtype' => 'text','text' => array ('content' => $message));
$data_string = json_encode($data);
$result = request_by_curl($webhook, $data_string);
echo $result;
?>
-------------------------
Re钉钉自定义机器人PHP版如何接入
找到问题了,因为提交的是https协议,所以需要加上 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
官方的demo也是这样的情况
赞0
踩0