Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
815 stars 343 forks source link

ssl #62

Closed mjavidm closed 7 years ago

mjavidm commented 7 years ago

hi, im using ssl from cloudflare when using as Dedicated IP and private ssl certificate bot not work please help me

mjavidm commented 7 years ago

how to set ssl certificate in webhook ?

Eleirbag89 commented 7 years ago

I'm still using the CloudFlare DNS for my bot, so all of my next advices are untested. If your server is correctly configured, you should be able to upload the cert file in the same folder of your bot script and run; $telegram->setWebhook("url", cert);

mjavidm commented 7 years ago

tnk u but if send pm to all member (1K member ) of bot CloudFlare give an eror 524

Eleirbag89 commented 7 years ago

put a timeot beetween the pm send

mjavidm commented 7 years ago

How?

Eleirbag89 commented 7 years ago

You need something like this:

$SECONDS_TO_WAIT = 10;
$USER_AT_ONCE = 10;

foreach ($users as &$user) {
    $i = 0;
   //Send Message
   $telegram->sendMessage(....);
   // Wait $SECONDS_TO_WAIT after every $USERS_AT_ONCE
   $i++;
   if ($i > $USERS_AT_ONCE) {
      $i = 0;
      sleep($SECONDS_TO_WAIT);
  }
}

Change the value of $SECONDS_TO_WAIT and $USER_AT_ONCE until you find the right combination

Eleirbag89 commented 7 years ago

This shoul take care of the timeout on the Telegram's front. For the CloudFlare read this; https://support.cloudflare.com/hc/en-us/articles/200171926-Error-524-A-timeout-occurred

"If you regularly run HTTP requests that take over 100 seconds to complete (for example large data exports), one alternative is to move those long-running processes to a subdomain that is not proxied by Cloudflare. That subdomain would have the orange cloud icon toggled to grey in the Cloudflare DNS Settings. "