当前位置: 首页>>代码示例>>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;未经允许,请勿转载。