DEF STUDIO srl

TelegraphResponse

all Telegraph requests return a TelegraphResponse that extends the original Illuminate\Http\Client\Response adding some useful methods:

All Illuminate\Http\Client\Response methods

As TelegraphResponse extends Illuminate\Http\Client\Response, it inherits all its methods:

$response = Telegraph::message('hello')->send();

$response->successful();
$response->ok();
$response->failed();
$response->body();
$response->json('path.to.json.data', 'default');

//.. and so on

telegraphOk

Returns true if the Telegram request is successful and contains ['ok' => true] in its body

$response = Telegraph::message('hello')->send();

$response->telegraphOk(); //true

telegraphError

Returns true if the Telegram request is not successful or is successful but doesn't contain ['ok' => true] in its body

$response = Telegraph::message('hello')->send();

$response->telegraphError(); //false

telegraphMessageId

Returns the ID of the message posted on the Telegraph chat (null if the request failed or no message was posted)

$response = Telegraph::message('hello')->send();

$response->telegraphMessageId(); //4568

dump

print a dump() of the response for testing purposes

$response = Telegraph::message('hello')->send();

$response->dump();

dd

print a dd() of the response for testing purposes

$response = Telegraph::message('hello')->send();

$response->dd();
Suggest a change
Last updated 03 October 2024