當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::getUpdates方法代碼示例

本文整理匯總了PHP中Longman\TelegramBot\Request::getUpdates方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getUpdates方法的具體用法?PHP Request::getUpdates怎麽用?PHP Request::getUpdates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Longman\TelegramBot\Request的用法示例。


在下文中一共展示了Request::getUpdates方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleGetUpdates

 /**
  * Handle getUpdates method
  *
  * @param int|null $limit
  * @param int|null $timeout
  *
  * @return \Longman\TelegramBot\Entities\ServerResponse
  */
 public function handleGetUpdates($limit = null, $timeout = null)
 {
     if (!DB::isDbConnected()) {
         return new Entities\ServerResponse(['ok' => false, 'description' => 'getUpdates needs MySQL connection!'], $this->bot_name);
     }
     //DB Query
     $last_update = DB::selectTelegramUpdate(1);
     //As explained in the telegram bot api documentation
     $offset = isset($last_update[0]['id']) ? $last_update[0]['id'] + 1 : null;
     $response = Request::getUpdates(['offset' => $offset, 'limit' => $limit, 'timeout' => $timeout]);
     if ($response->isOk()) {
         //Process all updates
         foreach ((array) $response->getResult() as $result) {
             $this->processUpdate($result);
         }
     }
     return $response;
 }
開發者ID:noplanman,項目名稱:php-telegram-bot,代碼行數:26,代碼來源:Telegram.php

示例2: handleGetUpdates

 /**
  * Handle getUpdates method
  *
  *
  */
 public function handleGetUpdates($limit = null, $timeout = null)
 {
     //DB Query
     $last_update = DB::selectTelegramUpdate(1);
     if (isset($last_update[0]['id'])) {
         //As explained in the telegram bot api documentation
         $offset = $last_update[0]['id'] + 1;
     } else {
         $offset = null;
     }
     $ServerResponse = Request::getUpdates(['offset' => $offset, 'limit' => $limit, 'timeout' => $timeout]);
     if ($ServerResponse->isOk()) {
         $results = '';
         $n_update = count($ServerResponse->getResult());
         for ($a = 0; $a < $n_update; $a++) {
             $result = $this->processUpdate($ServerResponse->getResult()[$a]);
         }
     }
     return $ServerResponse;
 }
開發者ID:isoroori,項目名稱:php-telegram-bot,代碼行數:25,代碼來源:Telegram.php

示例3: handleGetUpdates

 /**
  * Handle getUpdates method
  *
  * @return \Longman\TelegramBot\Telegram
  */
 public function handleGetUpdates($limit = null, $timeout = null)
 {
     //DB Query
     $last_message = DB::selectMessages(1);
     if (isset($last_message[0]['update_id'])) {
         //As explained in the telegram bot api documentation
         $offset = $last_message[0]['update_id'] + 1;
     } else {
         $offset = null;
     }
     //arrive a server Response object
     $ServerResponse = Request::getUpdates(['offset' => $offset, 'limit' => $limit, 'timeout' => $timeout]);
     if ($ServerResponse->isOk()) {
         $results = '';
         $n_update = count($ServerResponse->getResult());
         for ($a = 0; $a < $n_update; $a++) {
             $result = $this->processUpdate($ServerResponse->getResult()[$a]);
         }
         print date('Y-m-d H:i:s', time()) . ' - Processed ' . $a . " updates\n";
     } else {
         print date('Y-m-d H:i:s', time()) . " - Fail fetch updates\n";
         echo $ServerResponse->printError() . "\n";
     }
     //return $results
 }
開發者ID:nodancejustsex,項目名稱:php-telegram-bot,代碼行數:30,代碼來源:Telegram.php

示例4: handleGetUpdates

 /**
  * Handle getUpdates method
  *
  * @param int|null $limit
  * @param int|null $timeout
  *
  * @return \Longman\TelegramBot\Entities\ServerResponse
  */
 public function handleGetUpdates($limit = null, $timeout = null)
 {
     //DB Query
     $last_update = DB::selectTelegramUpdate(1);
     //As explained in the telegram bot api documentation
     $offset = isset($last_update[0]['id']) ? $last_update[0]['id'] + 1 : null;
     $response = Request::getUpdates(['offset' => $offset, 'limit' => $limit, 'timeout' => $timeout]);
     if ($response->isOk()) {
         //Process all updates
         foreach ((array) $response->getResult() as $result) {
             $this->processUpdate($result);
         }
     }
     return $response;
 }
開發者ID:juananpe,項目名稱:php-telegram-bot,代碼行數:23,代碼來源:Telegram.php


注:本文中的Longman\TelegramBot\Request::getUpdates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。