本文整理汇总了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;
}
示例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;
}
示例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
}
示例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;
}