H
H
hollanditkzn2017-07-28 17:30:21
Yii
hollanditkzn, 2017-07-28 17:30:21

How to get chat_id and write it to mysql user db?

I don’t understand a little how to implement so that the interceptor receives a chat_id and how I can put this chat_id in a user in the telegram_chat_id table. In order for the system to send a notification to this user.
I already wrote https://api.telegram.org/bot?url= on the command line. Returned {"ok":true,"result":true,"description":"Webhook was set"}. I have not programmed yet, but I have a question, only this one. Because I have never worked with api and it's hard to imagine how it's done

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-07-28
@hollanditkzn

Predictably, all this is in the documentation.
Here is an example code:

$content = file_get_contents('php://input');
$update = json_decode($content, TRUE);
$message = $update['message'];
$chat_id = $message['chat']['id'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question