2015-09-05 129 views
0

电报API say如何在发送Webhook答案的同时对电报Bot API执行请求?

如果您正在使用网络挂接,可以同时发送答案的网络挂接进行到机器人API的请求。

我试图通过这个简单的代码来做到这一点:

header('Content-Type: application/x-www-form-urlencoded'); 
$content = http_build_query(array(
    'method' => 'sendMessage', 
    'chat_id' => 123, 
    'text' => 'test 123' 
)); 
file_put_contents("php://output", $content); // or echo $content; 

,但我看不到机器人任何回应。

回答

0

电报更新robot API在最后一天,现在支持JSON响应。 所以我们可以改变代码:

header('Content-Type: application/json'); 
echo json_encode(array(
    'method'=>'sendMessage', 
    'text'=>'test 123', 
    'chat_id'=>123, 
)); 
die; 

它适用于我!