I’m quite a newbye in Telegram and I’m trying moving my first steps with it.
I’ve found a good tutorial here https://www.youtube.com/watch?v=hJBYojK7DO4: I’ve configured my Apache 2.4 with PHP and SSL and all works fine, also the samples in the tutorial.
Troubles are using the setWebhook method …. when I try to put in my browser
https://api.telegram.org/<my_bot_code>/setWebHook?url=https://localhost/Telegram/MyYouTubeTutorialBot/YouTubeTutorialBot.php
the response is
{"ok":false,"error_code":400,"description":"Error: Bad webhook: Error: Ip is reserved"}
Note that I’m using a self generated certificate ….
I’ve found in the api Telegram documentation (ref. https://core.telegram.org/bots/faq#i-39m-having-problems-with-webhooks), that
“….. To use a self-signed certificate, you need to upload your public key certificate using the certificate parameter in setWebhook. Please upload as InputFile, sending a String will not work.“
I don’t understand how to upload my public key certificate file …. any examples somewhere?
The problem could be because I’m using localhost and the default IP address 127.0.0.1 for my local Apache? Should I change my IP address using the current one that change every time I connect to the web (I’m using a internet key to connect me to the web …..)?
Thank you very much in advance
3
Answers
The following library allows you to easily do that (and quickly set up a bot):
https://github.com/auino/php-telegram-bot-library
It essentially calls Telegram’s
setWebhook
function/page, passing the self-signed certificate as a file, via aPOST
request:If you want to use
php-telegram-bot-library
, you can easily set it up through the install.php file, or using the following code (it works on Linux, it should work too on Windows systems):your local machine is not accessible over Internet by
localhost
or your local IP (127.0.0.1
) or local network IP (192.168.1.2
)each machine has it self’s
localhost
so telegram’s servers localhost is different with your’syou should to use a
web hosting
orVPS
to run your script and use its addressI know a free developer VPS : heroku
use following simple html code