腾讯最近新推出了一个hoo!k机器人,可以通过post请求来控制机器人在群里发送一些消息,但是这个需要有一定技术才会搞,所以我写了一个php文件来使这个过程更简单。
步骤
1.首先在自己的服务器上新建一个php文件,然后粘贴下面代码
php代码:
<?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);}$url = "http://52php.cnblogs.com";$jsonStr = json_encode(array('a' => 1, 'b' => 2, 'c' => 2));list($returnCode, $returnContent) = http_post_json($url, $jsonStr);?>

