Callback_data和PHP更新

时间:2019-03-17 21:16:30

标签: php updates telegram-bot php-telegram-bot

在使用php中的sendMessage(文本)和Callbackdata(内联按钮)的Telegrambot中

使用$ update [“ message”]时,读取写入的文本,并在$ update [“ callback_query”]行(第7和8行)中出现错误,并且如果我使用带有callback_data的按钮来检索在$ message = $ update [“ message”],(第1行和第2行)的行中显示错误的文本

错误是PHP注意:未定义的索引:第7/8行中的callback_query或在其他情况下PHP注意:未定义的索引:第1/3行中的消息

1    $message = $update["message"];
2    $text = $message["text"];
3    $chatid = $update["message"]["from"]["id"];
4    $from = $message["from"];
5    $username = $from["username"];
6
7    $callback_id = $update["callback_query"]["from"]["id"];
8    $callbackdata = $update["callback_query"]["data"];

否则,代码可以正常工作,但是我想知道如何清除错误

0 个答案:

没有答案