Example #1
0
 /**
  *  
  */
 protected function webhook()
 {
     $status = attrib('status');
     switch (strtolower($status)) {
         case 'on':
             put('根據測試, 必須夾帶 crt 檔案才能正確設定 web hook, 請手動設定.');
             /*
             $telegram = new \Telegram\Bot\Api(conf('bot.token'));
             $response = $telegram->setWebhook([
                 'url' => conf('bot.hook_file')
             ]);
             put( $response );
             */
             return;
         case 'off':
             // 該指令關閉 web hook, 通常用於開發環境
             $telegram = new \Telegram\Bot\Api(conf('bot.token'));
             $response = $telegram->removeWebhook();
             put($response->getDecodedBody());
             return;
         default:
             break;
     }
     put('fail');
 }
Example #2
0
<?php

/**
 * @author Adam Szewera
 */
include 'vendor/autoload.php';
$config = (require 'config.php');
$telegram = new \Telegram\Bot\Api($config['api_key']);
$url = 'http://' . $config['domain'] . '/CatalystBot/webhook.php';
$result = $telegram->setWebhook($url, $config['certificate_path']);
echo "set up";