irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
3.02k stars 669 forks source link

Store telegram user's chat_id in my database #92

Closed pfloriginale closed 8 years ago

pfloriginale commented 8 years ago

For first i need to say: Great job man!

It look like works... only one difficult to understand what exactly is a "webhook" and so...

HOW I could easy store the chat_id of a telegram user in the database of my app... it will be fantastic that it appen only by pressing a button.

Thank a lot!

irazasyed commented 8 years ago

Thanks!

Here are some informations about webhook: https://www.wikiwand.com/en/Webhook https://core.telegram.org/bots/api#setwebhook

In simple words, Once you setup an incoming webhook, Telegram will ping that URL with the update payload, So you need not do polling (Making getUpdates request every few seconds or so) to check if there's any new message. As soon as someone sends a message to your bot, your URL will be triggered by their system (POST request). Hopefully you got it. if not, Google has plenty of tutorials and information for you to understand in-depth.

As far as storing information into your database is concerned, that's something you need to do that yourself as this is just an API library that's making things easier for you to interact with Telegram's Bot API. But i do have plans to setup a bootstrap sometime in future for people to get started quickly with all the basic migrations and all in Laravel.