Php 如何在向webhook发送应答时执行对telegram Bot API的请求?

Php 如何在向webhook发送应答时执行对telegram Bot API的请求?,php,telegram,telegram-bot,Php,Telegram,Telegram Bot,电报API: 如果您使用的是webhook,则可以在向webhook发送应答的同时执行对Bot API的请求 我尝试通过以下简单代码来实现: header('Content-Type: application/x-www-form-urlencoded'); $content = http_build_query(array( 'method' => 'sendMessage', 'chat_id' => 123, 'text' => 'test 123

电报API:

如果您使用的是webhook,则可以在向webhook发送应答的同时执行对Bot 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;
但是我在机器人中看不到任何响应。

上一天的电报更新,现在支持JSON响应。 因此,我们可以更改代码:

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

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

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

这对我很有用

可以在json响应中发送多条消息吗?比如2或3条信息。也许如果我们使用数组。@OmidSadeghi nois是否可以在json响应中发送多条消息?比如2或3条信息。也许我们可以使用数组。@OmidSadeghi否