【发布时间】:2017-01-08 22:00:43
【问题描述】:
对不起,如果我的问题太混乱了,我是新来的,所以,欢迎任何建议。
如何区分“消息”更新和“回调查询”更新? 我已经设法制作了一个内联键盘,但是当我使用它时,机器人只是挂起,他没有回复任何内容。我做了一些研究,发现了this question,它帮助我理解了问题,但没有太多。
我的机器人现在使用这样的东西:
// read incoming info and grab the chatID
$content = file_get_contents("php://input");
$update = json_decode($content, true);
$chatID = $update["message"]["chat"]["id"];
switch($update["message"]["text"]){
/* insert magic here */
}
因此,此代码可以处理消息,但不能处理 CallbackQueries。如果我想要处理它们,我可以使用这样的东西(基于另一个问题的答案):
$callback_query = $update["callback_query"]
/* same as above */
但是如何判断是消息还是回调查询呢?
【问题讨论】: