HOO!K QQ官方机器人发送消息接口源码

QQ新出了个Webhook机器人HOO!K,目前只能发送消息!但它是腾讯官方的,所以不用担心风控等问题。

HOO!K-1

使用方法

  • 想要调用机器人需要先加HOO!K (2854196399)为好友

  • 然后把机器人添加到群聊

  • 在群成员列表点击HOO!K头像,按照下图步骤操作

HOO!K-2

  • 操作完成后就可以通过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);
?>

演示

HOO!K-3

HOO!K-4

HOO!K-5

总结

  • 只能发送消息
  • 发送不了主流后缀的链接如 .com .cn
  • 图新鲜可以玩玩