Skip to content

API Requests & Responses

Setiawan edited this page Aug 18, 2020 · 9 revisions

Requests

For convenience, we may pass a TelegramObject to the first argument of all the wrapped methods which contain the target method payload. Its fields will be sent as payload.

example:

$payload = new TelegramObject();
$payload->peer = '@your_username';
$payload->message = 'Your Message';

Messages::sendMessage($payload);

The TelegramObject's constructor also accepting array arguments:

$payload = new TelegramObject([
    'peer' = '@your_username',
    'message' = 'Your Message'
]);

Messages::sendMessage($payload);

Responses

All wrapped methods return a TelegramObject instance which wrapping the array response from Telegram api into an "object notated" response. The TelegramObject implements the Illuminate\Contracts\Support\Arrayable contract.

examples:

$response = Messages::sendMessage('@your_username', 'Your Message');

dd($response->toArray());

Wrapped apis

Clone this wiki locally