php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.87k stars 951 forks source link

self-signed certificates #35

Closed WISTFUL12 closed 8 years ago

WISTFUL12 commented 9 years ago

I use Webhook Method and when I open my set.php via browser, I get "Webhook was set" message. but: The bot doesn't reply The log file is empty

My server has self-signed certificate. I don't know how can I set public key certificate according https://core.telegram.org/bots/api#setwebhook method.

WISTFUL12 commented 9 years ago

In Certificate section of my control panel (kloxo) there are 3 key:

  1. CSR : -----BEGIN CERTIFICATE REQUEST----- -----END CERTIFICATE REQUEST-----
  2. Certificate : -----BEGIN CERTIFICATE----- -----END CERTIFICATE-----
  3. Key : -----BEGIN PRIVATE KEY----- -----END PRIVATE KEY-----

I upload content of section 2 on "http://www.xxx.com/telegram-bot-master/certificate" file

then edit /vendor/longman/telegram-bot/src/Request.php file and change setWebhook() function: public static function setWebhook($url) { $certificate = 'https://www.xxx.com/telegram-bot-master/certificate'; $result = self::send('setWebhook', array('url' => $url, 'certificate' => $certificate)); return $result; }

Is this actions true?

MBoretto commented 9 years ago

Hello, self-signed certificate has been introduced at the end of august in the telegram bot api. The bot method setWebhook actually don't support self signed certificate. The action you're trying to do is not correct because as explain in the telegram bot api: "Must be posted using multipart/form-data in the usual way that files are uploaded via the browser". Here's the fist example that i found: http://vedovini.net/2009/08/posting-multipart-form-data-using-php/

WISTFUL12 commented 9 years ago

Hello MBoretto, Do you think my issue (bot doesn't reply to /echo command & log file is empty) related to self-signed certificate or uploading certificate is an optional option?

I have tested sendMessage and getUpdates methods by API direct URL successfully.

Also when I try getUpdate Method and run ./getUpdatesCLI.php, I get below error on my error log: [17-Sep-2015 10:12:08] PHP Catchable fatal error: Object of class Longman\TelegramBot\Entities\ServerResponse could not be converted to string in /home//.com/php-telegram-bot-master/vendor/longman/telegram-bot/src/Request.php on line 80

MBoretto commented 9 years ago

Try to disable logging. It should be the source of the problem. Let me know..

WISTFUL12 commented 9 years ago

Thank a lot... I taged "$telegram->setLogRequests(true);" and "$telegram->setLogPath($BOT_NAME.'.log');" lines from "getUpdatesCLI.php" and "hook.php"

Now when I run "#php getUpdatesCLI.php" (in getUpdate method), I get "Processed 19 updates " message and data writhed on MySQL tables and bot replies to all entered commands.... Do I have to run "#php getUpdatesCLI.php" periodically by cron In this method?

Then I open my "set.php" via browser and get "Webhook was set" message. But The bot doesn't reply yet. for see activity on Webhook methode, what action I must to do?

MBoretto commented 9 years ago

Yes you have to run it periodically. Let's fix the logging problem and then we can understand better the others.

MBoretto commented 8 years ago

Self signed certificate can be uploaded since 0.21.0