How to use setWebhook in Telegram with self certificates on Windows 7 and PHP?

Cesare picture Cesare · Oct 27, 2015 · Viewed 14.6k times · Source

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

Answer

Hamid s k picture Hamid s k · Feb 21, 2017

use following simple html code

<html>
<body>

<form action="https://api.telegram.org/bot<BOT_TOCKEN>/setwebhook" method="post" enctype="multipart/form-data">
    Select Certificate to upload:
    <input type="file" name="certificate" id="fileToUpload">
	URL: <input type="text" name="url"  value="https://<YOURWEBSITE>/<YOUR_PHP_URL>"><br>
    <input type="submit" value="Upload Certificate" name="submit">
</form>

</body>
</html>