First of all, create bot at @botfather by searching botfather and send him the following command:

Fill in the long name and user name for the bot when @botfather is prompting for this.

You will now get back a Bot ID and Hash.
Save this ID and Hash in your PHP file.

In telegram send your newly create bot a message and go and fetch the Chat_ID

Browse to the following page using your own telegrambot values:
Please note the part where it says bot in front of your Bot ID!

Search for the part “Chat” and look for the “ID“.
Place this ID underneath your $telegrambot value in your PHP file.

Now go and create a page with the current function and code.

In the end its just 3 lines of code with a small function.
You can place the Bot ID and Chat ID in a config.php file and place the function in a seperate functions.php file. This way you can call this function from all your pages, create API’s and so forth…

When you are done you can message the botfather again to customize your bot with his own profile picture, description, etc.

Categorie: Android