E
E
eyyuioa2018-04-15 14:52:17
PHP
eyyuioa, 2018-04-15 14:52:17

Telegram PHP API how to get data from object?

I'm trying to get data from the User object from the telegrams of the bot, but for some reason I get an empty variable instead, please tell me what I'm doing wrong:

$data = json_decode(file_get_contents('php://input'));
function tgQuery($method, $params)
{
file_get_contents("https://api.telegram.org/bot".TOKEN."/".$method."?".$params);
}
$varg = $data->User->id;
tgQuery("sendMessage", "chat_id=".$data->message->chat->id."&text=TexL: ".$varg.".");

Ps I know that everything is very bad here, but so far I'm not interested in the correctness of the code, but the very fact of interaction with the bot. Thanks for understanding.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eyuioa, 2018-04-19
@eyuioa

Again, my stupidity, the data had to be requested first.) The question is closed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question