Telegram\Bot\Api::setWebhook PHP Method

setWebhook() public method

$params = [ 'url' => '', 'certificate' => '', ];
public setWebhook ( array $params ) : TelegramResponse
$params array
return TelegramResponse
    public function setWebhook(array $params)
    {
        if (filter_var($params['url'], FILTER_VALIDATE_URL) === false) {
            throw new TelegramSDKException('Invalid URL Provided');
        }
        if (parse_url($params['url'], PHP_URL_SCHEME) !== 'https') {
            throw new TelegramSDKException('Invalid URL, should be a HTTPS url.');
        }
        return $this->uploadFile('setWebhook', $params);
    }

Usage Example

Example #1
0
 /**
  * App constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->match('/', function () {
         return '/';
     });
     /**
      * process messages
      */
     $this->match('update', function () {
         $telegram = new Client(BOT_TOKEN);
         $handler = new Handler($telegram);
         return $handler->handle();
     });
     /**
      * update hook settings/api
      */
     $this->match('hook', function () {
         $telegram = new Api(BOT_TOKEN);
         $telegram->removeWebhook();
         if (USE_WEBHOOK) {
             $telegram->setWebhook(WEBHOOK, '../server-setup/files/cert/nginx.crt');
             return 'hook set';
         }
         return 'hook-removed';
     });
 }
All Usage Examples Of Telegram\Bot\Api::setWebhook