According to the Official Bots API :
Getting updates There are two mutually exclusive ways of receiving updates for your bot β the getUpdates method on one hand and Webhooks on the other.
So PHP bot script works differently, getting a schema
Use getUpdates
Access to the bot API is via HTTP GET / POST, in detail in the official help.
- Use an infinite loop to read messages from a telegram using HTTP GET / POST
If there are new posts
- Message parsing
- Send HTTP GET / POST message
- Sleep a few seconds
Use webhook
When using WebHook (and a well-tuned one), a new message to your bot will trigger an HTTP POST request from the telegram server to your configured URL on your own server, analyzed by your PHP script.
In your PHP script, parse the new message from HTTP POST and send the message from HTTP POST to the telegram server.
Thus, the difference only exists when receiving messages from a telegram, all responses are sent to the telegram via HTTP GET / POST, in detail in the Request Execution section in the official API.
Some people are crazy about the unofficial PHP api on github:
Fwolf
source share