Telegram BOT - setWebhook not working

I am new to creating telegram bots, and I really don't know where to start. The only thing I know about is PHP.

Ease of installation I have installed VPS with Windows Server 2008 R2 and I made a self-signed certificate using

openssl req -newkey rsa:2048 -sha256 -nodes -keyout server.key -x509 -days 365 -out server.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE" 

Then I converted PEM to CER using

 openssl x509 -inform PEM -in server.pem -outform DER -out server.cer 

I have a WAMP server installed and it should work with server.cer and server.key as a certificate and key, then I'v tested HTTPS (443), and it worked.

Then I installed the REST client on chrome and sent the URL of the bot.php and PEM file as data with several forms, as indicated in the official documentation.

Now I get this error:

 { ok: false, error_code: 400, description: "Error: Bad webhook: Posix Error: Success: getaddrinfo: Name or service not known" } 

and ... I'm here now !: | I ask you for help. What is the problem and how can I solve it?

Thank you in advance:)

NOTE. I don’t have a domain in which I use my VPS IP address

+6
source share
1 answer

Telegram requires a valid ssl certificate for your domain .

I will tell you how I decided it.

You can use NGROK, which can expose a local ip to the Internet with a temporary domain and https enabled.

Installation link - https://ngrok.com/

After installation, just run in the console:

 ngrok http 127.0.0.1:8003 

(ofc use the correct ip and port)

and you will get a free temporary domain (it will look like https://f9eb2f08.ngrok.io ) with https enabled.

Then set the URL of the new domain as the webhook_url telegram, and bot requests will be sent to your local server while NGROK is running.

0
source

All Articles