Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 1833a18

Browse files
committed
Added send-contact.php example
1 parent 0b866d3 commit 1833a18

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

examples/send-contact.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
include __DIR__ . '/basics.php';
6+
7+
use React\EventLoop\Factory;
8+
use unreal4u\TelegramAPI\HttpClientRequestHandler;
9+
use unreal4u\TelegramAPI\Telegram\Methods\SendContact;
10+
use unreal4u\TelegramAPI\TgLog;
11+
12+
$loop = Factory::create();
13+
$tgLog = new TgLog(BOT_TOKEN, new HttpClientRequestHandler($loop));
14+
15+
$sendInvoice = new SendContact();
16+
$sendInvoice->chat_id = A_USER_CHAT_ID;
17+
$sendInvoice->phone_number = '+420123456789';
18+
$sendInvoice->first_name = 'Tomas';
19+
$sendInvoice->last_name = 'Palider';
20+
$sendInvoice->vcard = 'BEGIN:VCARD
21+
VERSION:3.0
22+
EMAIL;TYPE=INTERNET:[email protected]
23+
END:VCARD';
24+
25+
$promise = $tgLog->performApiRequest($sendInvoice);
26+
27+
$promise->then(
28+
function ($response) {
29+
echo '<pre>';
30+
var_dump($response);
31+
echo '</pre>';
32+
},
33+
function (\Exception $exception) {
34+
// Onoes, an exception occurred...
35+
echo 'Exception ' . get_class($exception) . ' caught, message: ' . $exception->getMessage();
36+
}
37+
);
38+
39+
$loop->run();

0 commit comments

Comments
 (0)