2016-11-05 1 views
0

irazasyed.github.ioメッセージを送信するための電文SDK ここに私のボットにメッセージを送信すると何も起こらず、返信が届かない場合 どこに問題がありますか?電報ボットメッセージを送信する

$update = json_decode(file_get_contents('php://input') , true); 
$chat_id = $update->getMessage->getChat->getId(); 
+0

私はかなり確信しているもののメソッドを持つオブジェクトを返しませんjson_decode'関数 ':

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(); ?> 
meun5

答えて

0

を交換しています。私が間違っている場合は私を修正しますが、 `$ update`オブジェクトにはそれらのメソッドがないことを示すエラーが表示されるはずです。 `json_decode`関数が返す必要のあるものの詳細については、その関数の[manual page](https://secure.php.net/manual/en/function.json-decode.php)を参照してください。
関連する問題