2015-09-05 131 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; 

它適用於我!