https://github.com/gingteam/telegram
Telegram's collection of data types and methods
https://github.com/gingteam/telegram
php symfony-serializer telegram
Last synced: about 2 months ago
JSON representation
Telegram's collection of data types and methods
- Host: GitHub
- URL: https://github.com/gingteam/telegram
- Owner: gingteam
- License: mit
- Created: 2023-01-12T15:06:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-30T15:36:35.000Z (about 3 years ago)
- Last Synced: 2024-04-19T16:43:36.170Z (almost 2 years ago)
- Topics: php, symfony-serializer, telegram
- Language: PHP
- Homepage: https://gingteam.github.io/telegram/index.html
- Size: 395 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This package provides Telegram data types and methods


[](https://github.com/gingteam/telegram/actions/workflows/test.yml)
## Example
You can implement your own object class:
```php
client = $client ?: HttpClient::create();
}
public function sendRequest(string $name, array $data = [])
{
$data = $this->getSerializer()->normalize((object) $data);
$endpoint = sprintf('%s/bot%s/%s', self::BOT_API_URL, $this->token, $name);
$response = $this->client->request('POST', $endpoint, [
'json' => $data,
])->toArray(false);
/** @var Response */
$response = $this->getSerializer()->denormalize($response, Response::class);
if ($response->getErrorCode()) {
throw new RuntimeException($response->getDescription());
}
return $response->getResult();
}
}
$telegram = new SimpleTelegram('{token}');
foreach ($telegram->getUpdates() as $update) {
echo $update?->getMessage()?->getFrom()?->getUsername()."\n";
}
```