{"id":14985393,"url":"https://github.com/unreal4u/telegram-api","last_synced_at":"2025-04-13T21:28:31.747Z","repository":{"id":3112994,"uuid":"48204676","full_name":"unreal4u/telegram-api","owner":"unreal4u","description":"Complete async capable Telegram bot API implementation for PHP7","archived":false,"fork":false,"pushed_at":"2024-01-11T15:08:58.000Z","size":2209,"stargazers_count":795,"open_issues_count":16,"forks_count":175,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-04-06T17:09:02.739Z","etag":null,"topics":["amphp","bot-api","composer","inline-bots","php","php7","reactphp","telegram","telegram-api","telegram-bot","wiki-page"],"latest_commit_sha":null,"homepage":"https://github.com/unreal4u/telegram-api/wiki","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unreal4u.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-17T23:59:19.000Z","updated_at":"2025-03-02T14:28:00.000Z","dependencies_parsed_at":"2024-06-18T12:29:25.592Z","dependency_job_id":"caccdbea-73bc-4791-ada6-1365e0e65180","html_url":"https://github.com/unreal4u/telegram-api","commit_stats":{"total_commits":422,"total_committers":21,"mean_commits":"20.095238095238095","dds":"0.32464454976303314","last_synced_commit":"70f478d211237dac769b690af45c72da4b2bf8a6"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unreal4u%2Ftelegram-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unreal4u%2Ftelegram-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unreal4u%2Ftelegram-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unreal4u%2Ftelegram-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unreal4u","download_url":"https://codeload.github.com/unreal4u/telegram-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248784774,"owners_count":21161177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amphp","bot-api","composer","inline-bots","php","php7","reactphp","telegram","telegram-api","telegram-bot","wiki-page"],"created_at":"2024-09-24T14:10:52.469Z","updated_at":"2025-04-13T21:28:31.719Z","avatar_url":"https://github.com/unreal4u.png","language":"PHP","readme":"[![PHP 7 Telegram Bot API Library](https://github.com/unreal4u/telegram-api/blob/master/examples/binary-test-data/logo-php7-telegram-bot-api-small.png?raw=true)](https://github.com/unreal4u/telegram-api/wiki/100-stars!)\n\n# Telegram API Library\n\n[![Latest Stable Version](https://poser.pugx.org/unreal4u/telegram-api/v/stable)](https://packagist.org/packages/unreal4u/telegram-api)\n[![Total Downloads](https://poser.pugx.org/unreal4u/telegram-api/downloads)](https://packagist.org/packages/unreal4u/telegram-api)\n[![Build Status](https://travis-ci.org/unreal4u/telegram-api.svg)](https://travis-ci.org/unreal4u/telegram-api)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/unreal4u/telegram-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/unreal4u/telegram-api/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/unreal4u/telegram-api/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/unreal4u/telegram-api/?branch=master)\n[![License](https://poser.pugx.org/unreal4u/telegram-api/license)](https://packagist.org/packages/unreal4u/telegram-api)\n\nThis is a PHP7 bot API implementation for Telegram implementing the **vast majority** of\n[Bot API up until v4.7](https://core.telegram.org/bots/api-changelog#march-30-2020). The only thing it does not implement\nis Telegram Passport which was introduced in [Bot API v4.0](https://core.telegram.org/bots/api#july-26-2018). It is\nunlikely to be introduced as it may introduce security vulnerabilities. However, if you think you have a strong case for\nthe need, feel free to let me know.\n\n### About this package\n\n* Enables you to anything supported by the Telegram Bot API: messages, stickers, location, inline bots and any other supported method via PHP to a Telegram user (either direct conversation, channel, group or supergroup).\n* Respects and implements the default types and methods made by Telegram itself. Have any doubts about any method? [Just check the original documentation](https://core.telegram.org/bots/api), this implementation will not differ too much.\n* Doesn't need any mandatory dependencies, except for ReactPHP, which you can inject if you already use it elsewhere.\n* **Full** inline bots support.\n* **Full** support for payment system.\n\n## Known bugs\n\n[![Telegram](http://trellobot.doomdns.org/telegrambadge.svg)](https://t.me/PHPBotAPI)\n\nThe only thing that is not included in this library (yet) is the Passport support. This was an ongoing development, but\nit ended up being a lot more work than initially thought, so if someone wants to pick that up... be my guest!\n\nAll other known bugs can be found in the form of issues or pull requests. Found a new bug? Feel free to [submit a PR](https://github.com/unreal4u/telegram-api/pulls) or\n[create an issue](https://github.com/unreal4u/telegram-api/issues)! Not sure if you've found a new bug? You can always ask\nin the [special group](https://t.me/PHPBotAPI) :)\n\n## Roadmap\n\n- v4 (no branch yet) will be the next major release. [More information](https://github.com/unreal4u/telegram-api/projects/5).\n- v3 (master branch) is the current active branch.\n- v2 (v2 branch) is deprecated and no new work will be done there.\n- v1 is deprecated and no new work will be done there.\n- v0 is deprecated and no new work will be done there.\n\n## Installation\n\n[![Total Downloads](https://poser.pugx.org/unreal4u/telegram-api/downloads)](https://packagist.org/packages/unreal4u/telegram-api)\n\nComposer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. [Read this for installation instructions](https://getcomposer.org/doc/00-intro.md).  \nThe preferred (and only for now) installation method is Composer, so add the following to your composer.json:\n\n```json\n{\n  \"require\": {\n    \"unreal4u/telegram-api\": \"~3.4\"\n  }\n}\n```\n\nIf you are not familiar with it, I suggest reading the basic usage manual [located here](https://getcomposer.org/doc/01-basic-usage.md).\n\n### Tip for Russian users\n\nIn order to use a proxy, you can use the https://github.com/clue/php-socks-react package and pass on the following options to the Client:\n\n```php\n\u003c?php\n\nuse Clue\\React\\Socks\\Client;\n\n$loop = Factory::create();\n// Replace PROXY_ADDRESS and PROXY_PORT with the correct configuration\n$proxy = new Client('socks5://' . PROXY_ADDRESS . ':' . PROXY_PORT, new Connector($loop));\n$handler = new HttpClientRequestHandler($loop, [\n    'tcp' =\u003e $proxy,\n    'timeout' =\u003e 3.0,\n    'dns' =\u003e false\n]);\n\n$this-\u003etgLog = new TgLog(BOT_TOKEN, $handler);\n// The rest is exactly the same as it normally is, see the examples folder for more information\n```\n\nWith these simple steps, a proxy is configured in no time!\n\n### Upgrading v2.x to v3\n\nA lot of backwards incompatibility changes, but in a nutshell: \n* ReactPHP is the new Guzzle (Async requests!)\n* Changed parameter order when invoking the constructor of `TgLog`\n* Custom -Array types now implement IteratorAggregate (Solves #21 !)\n\nPlease check [the following Wiki page](https://github.com/unreal4u/telegram-api/wiki/Upgrading-from-v2-to-v3) if you \nhave to upgrade from v2 to v3.\n\n## General usage\n\n### Basic usage example:\n\n```php\n\u003c?php\n\nuse \\unreal4u\\TelegramAPI\\HttpClientRequestHandler;\nuse \\unreal4u\\TelegramAPI\\TgLog;\nuse \\unreal4u\\TelegramAPI\\Telegram\\Methods\\SendMessage;\n\n$loop = \\React\\EventLoop\\Factory::create();\n$handler = new HttpClientRequestHandler($loop);\n$tgLog = new TgLog(BOT_TOKEN, $handler);\n\n$sendMessage = new SendMessage();\n$sendMessage-\u003echat_id = A_USER_CHAT_ID;\n$sendMessage-\u003etext = 'Hello world!';\n\n$tgLog-\u003eperformApiRequest($sendMessage);\n$loop-\u003erun();\n```\n(Side note: In case `React\\EventLoop\\Factory` cannot be resolved in the above code, add `include('vendor/autoload.php')` to your PHP file).\n\nWith the `SendMessage()` object, you can create a message to be sent through the TgLog object.  \nAll other functionality is based upon this behaviour, so every other method is very similar: you instantiate an object, \npass that object to TelegramLog-\u003eperformApiRequest(), which will return a Promise. If the method returns a reply, \npass a callback to its `onFulfilled` parameter and you'll get the native Telegram response back as an object. \nDifferent methods return different object types. \n\nPlease refer to the [examples directory](https://github.com/unreal4u/telegram-api/tree/master/examples) to view examples \nof some of the implemented methods, including inline bots. \n\nFor examples of actual code that works in a production environment, please refer to my other repo: https://github.com/unreal4u/telegram-bots\n\n### Getting updates via Webhook\n\nPlease check [the following wiki section](https://github.com/unreal4u/telegram-api/wiki/Getting-updates-via-Webhook) for\nmore information on this.\n\n### Inline bots\n\nPlease checkout the [special wiki page](https://github.com/unreal4u/telegram-api/wiki/Inline-Bots) about inline bots.\n\n### Extra requirements\n\nIf you want to use this package, you'll need a bot API key. Check \n[the following documentation](https://github.com/unreal4u/telegram-api/wiki/Creating-a-bot) for more instructions \non that.\n\n### Getting everything started up\n\nThe most difficult thing to do when performing an action with the Telegram API is to get the chat_id, which is the \nactual conversation window the bot talks to. You can execute the GetUpdates() method in order to get this chatId. Note\nthat there are some caveats on this, so you may be better out with the SetWebhook() method instead. \n\n## Development\n\n### Semver\n\nI will try my best to respect [Semantic Versioning](http://semver.org).  \nThat being said, the first stable release is v1.0.0, from there on no mayor BC changes will occur unless we update\nthe major.\n\n### Want to colaborate?\n\nCollaborations are **very** welcome! [Check this Wiki page out](https://github.com/unreal4u/telegram-api/wiki/Want-to-colaborate%3F) \nfor more information that will make the development easier!\n\n### Contact the author\n\n[![Telegram](http://trellobot.doomdns.org/telegrambadge.svg)](https://t.me/PHPBotAPI)\n\nI actually don't use Telegram. Nah, kidding, I created a group where you can contact me at [https://t.me/PHPBotAPI](https://t.me/PHPBotAPI).\nAnother great way to get in touch is to simply [create an issue](https://github.com/unreal4u/telegram-api/issues) or a\n[pull request](https://github.com/unreal4u/telegram-api/pulls)!\n\n### Bugs related with security\n\nI would appreciate it if you could handle these responsibly. If you happen to find a security issue relating to this \nTelegram Bot API client, please ask me to contact you privately [over here](https://t.me/PHPBotAPI).\n\n### Special thanks to\n\n- :+1: A VERY (!!) special thanks to **[NanoSector](https://github.com/Yoshi2889)** for making the entire API async worthy!\n- :+1: **Intensify** for reporting [this fatal error](https://github.com/unreal4u/telegram-api/issues/15).\n- :+1: All the amazing people who make [issues](https://github.com/unreal4u/telegram-api/issues) and [pull requests](https://github.com/unreal4u/telegram-api/pulls)!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funreal4u%2Ftelegram-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funreal4u%2Ftelegram-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funreal4u%2Ftelegram-api/lists"}