Skip to content

Getting updates via Webhook

Camilo Sperberg edited this page Nov 21, 2016 · 5 revisions

The first thing you'll have to do is register a webhook with Telegram via the SetWebhook method:

use \unreal4u\TelegramAPI\TgLog;
use \unreal4u\TelegramAPI\Telegram\Methods\SetWebhook;

$setWebhook = new SetWebhook();
$setWebhook->url = '[YOUR HTTPS URL]';

$tgLog = new TgLog(BOT_TOKEN);
$tgLog->performApiRequest($setWebhook);

This will leave you prepared to start receiving updates on the chosen URL:

use \unreal4u\TelegramAPI\Telegram\Types\Update;

$update = new Update($_POST);

Now $update will contain the actual Update object. Hope that wasn't too difficult :)

More information on this? You can check how I implemented my timeBot. Take however into account that the cited repo is only a playground (for now), so it can happen that things in that repository may or may not work as expected.

Clone this wiki locally