想要调用机器人需要先加HOO!K (2854196399)
为好友
然后把机器人添加到群聊
在群成员列表点击HOO!K
头像,按照下图步骤操作
操作完成后就可以通过POST请求来控制机器人在群里发送消息了,我们可以用下面这个PHP文件使过程变简单。
使用方法:https://xxx.xxx/qqhook.php?str=消息内容
<?php
$str = $_GET['str'];
$url = "替换为你的webhook地址";
$jsonStr = '{"content": [ {"type":0,"data":"'.$str.'"}]}';
http_post_json($url,$jsonStr);
function http_post_json($url, $jsonStr)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($jsonStr)
)
);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array($httpCode, $response);
}
$jsonStr = json_encode(array('a' => 1, 'b' => 2, 'c' => 2));
list($returnCode, $returnContent) = http_post_json($url, $jsonStr);
?>
.com
.cn
等