【发布时间】:2017-03-19 07:27:54
【问题描述】:
我正在使用 irazasyed.github.io Telegram SDK 发送消息 这是我向机器人发送消息时的代码,没有任何反应,也没有收到回复 问题出在哪里 ?
MY_BOT_TOKEN 被替换
<?php
require 'vendor/autoload.php';
use Telegram\Bot\Api;
$telegram = new Api('MY_BOT_TOKEN');
$update = json_decode( file_get_contents( 'php://input' ) );
$chat_id = $update->getMessage()->getChat()->getId();
$response = $telegram->sendMessage([
'chat_id' => $chat_id;
'text' => 'Hello World'
]);
$response->getMessageId();
?>
【问题讨论】:
-
我相当肯定函数
json_decode不会返回具有这些方法的对象。如果我错了,请纠正我,但您应该会收到一条错误消息,指出$update对象没有这些方法。有关json_decode函数应返回什么的更多信息,请查看该函数的 manual page。