php - Answer callback query
Get the solution ↓↓↓I have a Telegram with multiple functions running ok. Now I'm trying to add some more actions on inline buttons, however I can't seem to get it done.
I've wrapped all my bot code into an if and added an else condition for when a callback is sent, all of my bot actions are unaffected and running fine but the callback section isn't working at all.
This is my code, what may be missing?
define ('url',"https://api.telegram.org/botTOKEN/");
if (isset($update['message'])) {
//MY USUAL BOT LOGIC, EVERYHTING HERE RUN JUST FINE
} else if (isset($update['callback_query'])) {
$callback_id = $update['callback_query']['id'];
file_get_contents(url."answerCallbackQuery?callback_query_id=$callback_$id&text=SUCCESS");
}
Thanks in advance,
Answer
Solution:
file_get_contents(url."answerCallbackQuery?callback_query_id=$callback_$id&text=SUCCESS");
You've saved thecallback_id
in$callback_id
, your are using$callback_$id
in the code!
Fixed;
file_get_contents(url."answerCallbackQuery?callback_query_id={$callback_id}&text=SUCCESS");
Try using{}
around inline strings so there easy to spot! More info about .
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot set properties of undefined (setting '_dt_cellindex')
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.