getUpdates() public method

\param $offset Integer Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. \param $limit Integer Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100 \param $timeout Integer Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling \param $update Boolean If true updates the pending message list to the last update received. Default to true. \return the updates as Array
public getUpdates ( $offset, $limit = 100, $timeout, $update = true )
コード例 #1
0
<?php

/**
 * Telegram Bot Example whitout WebHook.
 * It uses getUpdates Telegram's API.
 * @author Gabriele Grillo <*****@*****.**>
 */
include "Telegram.php";
$bot_id = "bot_token";
$telegram = new Telegram($bot_id);
// Get all the new updates and set the new correct update_id
$req = $telegram->getUpdates();
for ($i = 0; $i < $telegram->UpdateCount(); $i++) {
    // You NEED to call serveUpdate before accessing the values of message in Telegram Class
    $telegram->serveUpdate($i);
    $text = $telegram->Text();
    $chat_id = $telegram->ChatID();
    if ($text == "/start") {
        $reply = "Working";
        $content = array('chat_id' => $chat_id, 'text' => $reply);
        $telegram->sendMessage($content);
    }
    if ($text == "/test") {
        if ($telegram->messageFromGroup()) {
            $reply = "Chat Group";
        } else {
            $reply = "Private Chat";
        }
        // Create option for the custom keyboard. Array of array string
        $option = array(array("A", "B"), array("C", "D"));
        // Get the keyboard