removeWebhook() public method

Removes the outgoing webhook (if any).
public removeWebhook ( ) : TelegramResponse
return TelegramResponse
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';
     });
 }
Example #2
0
<?php

require_once 'EDITME/config.php';
require_once 'boot.php';
use Telegram\Bot\Api;
$telegram = new Api($BOTTOKEN);
$response = $telegram->removeWebhook();
echo "<pre>";
print_r($response);
echo "</pre>";
Example #3
0
File: midna.php Project: e0th/Midna
namespace Midna;

use RedBeanPHP\R;
use Telegram\Bot\Api;
require_once __DIR__ . '/../../vendor/autoload.php';
define('MIDNA_TOKEN', 'xxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('MIDNA_HOOK', 'https://example.com/path/to/this/file.php');
define('MIDNA_CERT', '/path/to/your/ssl/certificate.pem');
$telegram = new Api(MIDNA_TOKEN);
R::setup('sqlite:' . __DIR__ . '/../../database/database.db');
$telegram->addCommand(new Commands\Start());
$telegram->addCommand(new Commands\Help());
$telegram->commandsHandler(true);
if (php_sapi_name() == 'cli') {
    if ($argv[1] == 'start') {
        print "Starting Midna" . PHP_EOL;
        $bean = R::dispense('messages');
        $bean->message_id = 0;
        $bean->message_date = 0;
        R::store($bean);
        $telegram->setWebhook(['url' => MIDNA_HOOK, 'certificate' => MIDNA_CERT]);
    } else {
        if ($argv[1] == 'stop') {
            print "Stopping Midna" . PHP_EOL;
            $telegram->removeWebhook();
        }
    }
    exit;
}
R::close();