{"id":13828383,"url":"https://github.com/formapro/telegram-bot-php","last_synced_at":"2025-04-05T00:09:04.351Z","repository":{"id":52144629,"uuid":"164605599","full_name":"formapro/telegram-bot-php","owner":"formapro","description":"PHP Telegram Bot.","archived":false,"fork":false,"pushed_at":"2021-05-06T20:53:23.000Z","size":53,"stargazers_count":252,"open_issues_count":7,"forks_count":61,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-04-24T18:55:31.281Z","etag":null,"topics":["php7","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":null,"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/formapro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-08T08:50:44.000Z","updated_at":"2024-04-24T18:55:31.282Z","dependencies_parsed_at":"2022-09-08T15:51:25.179Z","dependency_job_id":null,"html_url":"https://github.com/formapro/telegram-bot-php","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formapro%2Ftelegram-bot-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formapro%2Ftelegram-bot-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formapro%2Ftelegram-bot-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formapro%2Ftelegram-bot-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/formapro","download_url":"https://codeload.github.com/formapro/telegram-bot-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266564,"owners_count":20910836,"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":["php7","telegram","telegram-bot"],"created_at":"2024-08-04T09:02:43.975Z","updated_at":"2025-04-05T00:09:04.323Z","avatar_url":"https://github.com/formapro.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# PHP Telegram Bot\n\nTelegram bot as it should be.\n\n## Examples\n\n### SetWebhook\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\SetWebhook;\nuse function GuzzleHttp\\Psr7\\str;\n\n$bot = new Bot('telegramToken');\n\n$setWebhook = new SetWebhook('https://your.app/telegram-updates-hook');\n\n// uncomment if use use self-signed certificate\n// $setWebhook-\u003esetCertificate(file_get_contents('/path/to/self-signed-certifcate.pem'));\n\n$response = $bot-\u003esetWebhook($setWebhook);\n\necho str($response);\n```\n\n### GetWebhookInfo\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse function GuzzleHttp\\Psr7\\str;\n\n$bot = new Bot('telegramToken');\n\n$response = $bot-\u003egetWebhookInfo();\n\necho str($response);\n```\n\n### SendMessage\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\nuse Formapro\\TelegramBot\\SendMessage;\n\n$requestBody = file_get_contents('php://input'); \n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n$bot = new Bot('telegramToken');\n$bot-\u003esendMessage(new SendMessage(\n    $update-\u003egetMessage()-\u003egetChat()-\u003egetId(),\n    'Hi there! What can I do?'\n));\n```\n\n### SendPhoto\n\n**Note:** if you want to send gif with many pictures inside - \nuse `sendDocument`\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\nuse Formapro\\TelegramBot\\SendMessage;\n\n$requestBody = file_get_contents('php://input');\n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n// You can pass URI of image or a path to file\n$picture = '/path/to/picture'; // OR https://some-server.com/some.jpg\n \n$sendPhoto = new SendPhoto(\n    $update-\u003egetMessage()-\u003egetChat()-\u003egetId(),\n    file_get_contents($picture) // or just $picture if it's url\n);\n\n// also you can set `caption` to image\n$sendPhoto-\u003esetCaption('Some caption under the picture');\n\n$bot = new Bot('telegramToken');\n$bot-\u003esendPhoto($sendPhoto);\n```\n\n### SendDocument\n\n**Note:** _sending by URL will currently only work for\ngif, pdf and zip files._ (from documentation)\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\nuse Formapro\\TelegramBot\\SendDocument;\nuse Formapro\\TelegramBot\\FileUrl;\nuse Formapro\\TelegramBot\\FileId;\nuse Formapro\\TelegramBot\\InputFile;\n\n$requestBody = file_get_contents('php://input');\n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n// You can pass URI of image or a path to file\n//$document = new FileUrl('https://some-server.com/some.pdf');\n\n// You can pass an ID of already stored file on Telegram side.\n//$document = new FileId('123');\n\n// You can pass local file.\n$document = new InputFile('test.txt', 'Hi there!');\n\n$sendDocument = SendDocument::withInputFile(\n    $update-\u003egetMessage()-\u003egetChat()-\u003egetId(),\n    $document\n);\n\n// also you can set `caption` to image\n$sendDocument-\u003esetCaption('Some caption under the document');\n\n$bot = new Bot('telegramToken');\n$bot-\u003esendDocument($sendDocument);\n```\n\n### SendInvoice\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\nuse Formapro\\TelegramBot\\SendInvoice;\n\n$requestBody = file_get_contents('php://input');\n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n$payload = []; // any params which you need to proccess in the transaction\n$providerToken = 'something:like:this'; // Token have to be taken from botFather\n\n$sendInvoice = new SendInvoice(\n    $update-\u003egetMessage()-\u003egetChat()-\u003egetId(),\n    'Your title',\n    'Your description of invoice',\n    json_encode($payload), \n    $providerToken,\n    '12314czasdq', // unique id\n    'UAH',\n    [new LabeledPrice('PriceLabel_1', 3001)] // amount; here 30.01 UAH\n);\n\n$bot = new Bot('telegramToken');\n$bot-\u003esendInvoice($sendInvoice);\n```\n\n### ReplyKeyboardMarkup\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\nuse Formapro\\TelegramBot\\SendMessage;\nuse Formapro\\TelegramBot\\KeyboardButton;\nuse Formapro\\TelegramBot\\ReplyKeyboardMarkup;\n\n$requestBody = file_get_contents('php://input'); \n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n$fooButton = new KeyboardButton('foo');\n$barButton = new KeyboardButton('bar');\n$bazButton = new KeyboardButton('bar');\n$keyboard = new ReplyKeyboardMarkup([[$fooButton], [$barButton, $bazButton]]);\n\n$sendMessage = new SendMessage($update-\u003egetMessage()-\u003egetChat()-\u003egetId(), 'Choose an option.');\n$sendMessage-\u003esetReplyMarkup($keyboard);\n\n$bot = new Bot('telegramToken');\n$bot-\u003esendMessage($sendMessage);\n```\n\nRequest Contacts:\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\nuse Formapro\\TelegramBot\\SendMessage;\nuse Formapro\\TelegramBot\\KeyboardButton;\nuse Formapro\\TelegramBot\\ReplyKeyboardMarkup;\n\n$requestBody = file_get_contents('php://input'); \n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n$button = new KeyboardButton('Share my contacts');\n$button-\u003esetRequestContact(true);\n$keyboard = new ReplyKeyboardMarkup([[$button]]);\n$keyboard-\u003esetOneTimeKeyboard(true);\n\n$sendMessage = new SendMessage($update-\u003egetMessage()-\u003egetChat()-\u003egetId(), 'Please, share your contact info with us.');\n$sendMessage-\u003esetReplyMarkup($keyboard);\n\n$bot = new Bot('telegramToken');\n$bot-\u003esendMessage($sendMessage);\n```\n\n### InlineKeyboardButton\n\nUrl: \n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\InlineKeyboardButton;\nuse Formapro\\TelegramBot\\InlineKeyboardMarkup;\nuse Formapro\\TelegramBot\\SendMessage;\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\n\n$requestBody = file_get_contents('php://input'); \n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n$button = InlineKeyboardButton::withUrl('inline button', 'https://your.app/link');\n$keyboard = new InlineKeyboardMarkup([[$button]]);\n        \n$sendMessage = new SendMessage($update-\u003egetMessage()-\u003egetChat()-\u003egetId(), 'Click on inline button.');\n$sendMessage-\u003esetReplyMarkup($keyboard);\n                \n$bot = new Bot('telegramToken');\n$bot-\u003esendMessage($sendMessage);\n```\n\nCallbackQuery: \n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\InlineKeyboardButton;\nuse Formapro\\TelegramBot\\InlineKeyboardMarkup;\nuse Formapro\\TelegramBot\\SendMessage;\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\n\n$requestBody = file_get_contents('php://input'); \n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\n$button = InlineKeyboardButton::withCallbackData('inline button', 'some_data');\n$keyboard = new InlineKeyboardMarkup([[$button]]);\n        \n$sendMessage = new SendMessage($update-\u003egetMessage()-\u003egetChat()-\u003egetId(), 'Click on inline button.');\n$sendMessage-\u003esetReplyMarkup($keyboard);\n                \n$bot = new Bot('telegramToken');\n$bot-\u003esendMessage($sendMessage);\n```\n\n## AnswerCallbackQuery\n\n```php\n\u003c?php\nuse Formapro\\TelegramBot\\AnswerCallbackQuery;\nuse Formapro\\TelegramBot\\Bot;\nuse Formapro\\TelegramBot\\Update;\n\n$requestBody = file_get_contents('php://input'); \n$data = json_decode($requestBody, true);\n\n$update = Update::create($data);\n\nif ($callbackQuery = $update-\u003egetCallbackQuery()) {\n    $bot = new Bot('telegramToken');\n    $bot-\u003eanswerCallbackQuery(new AnswerCallbackQuery($callbackQuery-\u003egetId()));\n}\n```\n\n## Developed by Forma-Pro\n\nForma-Pro is a full stack development company which interests also spread to open source development. \nBeing a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker \u0026 microservice oriented architecture where we have accumulated a huge many-years experience. \nOur main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture \u0026 scalability.\n\nIf you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at opensource@forma-pro.com\n\n## License\n\nIt is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformapro%2Ftelegram-bot-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fformapro%2Ftelegram-bot-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformapro%2Ftelegram-bot-php/lists"}