对关注的事务及时提醒 更多专注生活
本功能根据钉钉开发
<?php
//钉钉机器人API
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,
['Content-Type: application/json;charset=utf-8']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码
// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
// 机器人hook地址,access_token需要更换成自己的token哦!
$token = "填写自己的token";
$webhook = "https://oapi.dingtalk.com/robot/send?access_token=$token";
$message = "币价监测Warning~【要事提醒-TEST】";
$isAtAll = false;
$data = [
'msgtype' => 'markdown',
'markdown' =>[
'title' => $message,
'text' => "## WBNB \n\r >当前价格:\$398\n\r >持有数量:120000\n\r >订单数量:120000\n\r >10点20分发布 [查看BNB走势图](https://dex.guru/token/0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c-bsc) \n",
],
];
$data_string = json_encode($data);
$result = request_by_curl($webhook, $data_string);
echo $result;