telegramBot::getWebhookUpdates PHP Method

getWebhookUpdates() public method

Works only if you set a webhook.
See also: setWebhook
public getWebhookUpdates ( ) : Array
return Array
    public function getWebhookUpdates()
    {
        $body = json_decode(file_get_contents('php://input'), true);
        return $body;
    }

Usage Example

Example #1
0
global $msg;
global $api;
global $sender;
global $db;
global $t;
$t = new Translator();
$db = new MySql();
$api = new telegramBot(TELEGRAM_API_TOKEN);
$pluginManager = new PluginManager();
$pluginManager->collectAliases();
if (defined("IS_CRONJOB")) {
    // Cronjob running
    // TODO
} else {
    // Message received
    $update = new Update($api->getWebhookUpdates());
    if ($update->type == "inlineQuery") {
    } else {
        $message = $update->message;
        $pluginManager->sendReceived($message);
        if ($message->is_command) {
            $cmd = $message->getCommand();
            if (!$cmd) {
                exit;
            }
            $cmd = $pluginManager->resolveAlias($cmd);
            $class = new $cmd();
            $class->execute($message);
        }
    }
}