简体   繁体   English

电报机器人发送消息

[英]Telegram bot Send message

I am using irazasyed.github.io Telegram SDK for sending message here is my code when I send message to bot nothing happen and no reply receives Where is the problem ? 我正在使用irazasyed.github.io Telegram SDK发送消息,这是我向机器人发送消息时没有发生任何反应且没有收到回复的代码。问题出在哪里?

MY_BOT_TOKEN is replaced 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();

?>

need to do some changes: 需要做一些改变:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM