{"id":23143412,"url":"https://github.com/sh20raj/phpgram","last_synced_at":"2025-10-08T15:06:31.367Z","repository":{"id":248867014,"uuid":"830020162","full_name":"SH20RAJ/phpgram","owner":"SH20RAJ","description":"A PHP library for interacting with the Telegram Bot API.","archived":false,"fork":false,"pushed_at":"2024-12-08T17:12:44.000Z","size":21,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T14:43:42.410Z","etag":null,"topics":["php","pi","telegram","telegram-bot","telegram-bot-api"],"latest_commit_sha":null,"homepage":"https://sh20raj.github.io/phpgram/","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/SH20RAJ.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-17T12:54:22.000Z","updated_at":"2025-07-30T16:39:56.000Z","dependencies_parsed_at":"2025-08-17T14:33:39.816Z","dependency_job_id":"9c5eda8c-bcd2-463f-aa3f-c48f2c39bfa5","html_url":"https://github.com/SH20RAJ/phpgram","commit_stats":null,"previous_names":["sh20raj/phpgram"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SH20RAJ/phpgram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fphpgram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fphpgram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fphpgram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fphpgram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SH20RAJ","download_url":"https://codeload.github.com/SH20RAJ/phpgram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fphpgram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278963956,"owners_count":26076566,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["php","pi","telegram","telegram-bot","telegram-bot-api"],"created_at":"2024-12-17T15:13:23.235Z","updated_at":"2025-10-08T15:06:31.352Z","avatar_url":"https://github.com/SH20RAJ.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PhpGram\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/SH20RAJ/phpgram/blob/main/LICENSE)\n[![PHP](https://img.shields.io/badge/PHP-%3E%3D%207.0-8892BF.svg)](https://www.php.net/)\n[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-%3E%3D%205.0-0088cc.svg)](https://core.telegram.org/bots/api)\n[![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2FSH20RAJ%2Fphpgram\u0026labelColor=%232ccce4\u0026countColor=%23f47373\u0026style=flat-square)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2FSH20RAJ%2Fphpgram)\n[![Latest Stable Version](https://img.shields.io/packagist/v/sh20raj/phpgram.svg?style=flat-square)](https://packagist.org/packages/sh20raj/phpgram)\n\n\nPhpGram is a PHP library for interacting with the Telegram Bot API, providing easy-to-use methods for sending messages, media, managing chats, stickers, inline queries, payments, and more.\n\n## Table of Contents\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Initialization](#initialization)\n  - [Basic Usage](#basic-usage)\n  - [Sending Messages and Media](#sending-messages-and-media)\n  - [Managing Chats and Members](#managing-chats-and-members)\n  - [Handling Stickers](#handling-stickers)\n  - [Inline Mode](#inline-mode)\n  - [Payments](#payments)\n  - [Games](#games)\n  - [Handling Updates](#handling-updates)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nInstall PhpGram via [Composer](https://packagist.org/packages/sh20raj/phpgram):\n\n```bash\ncomposer require sh20raj/phpgram\n```\n\nAlternatively, you can clone the repository:\n\n```bash\ngit clone https://github.com/SH20RAJ/phpgram.git\n```\n\n## Usage\n\n### Initialization\n\nFirst, include the library in your PHP file and initialize `PhpGram` with your bot token:\n\n```php\nrequire __DIR__ . '/../src/PhpGram.php';\n\nuse PhpGram\\PhpGram;\n\n$token = 'YOUR_BOT_TOKEN';\n$bot = new PhpGram($token);\n```\n\n### Basic Usage\n\n\u003e Try Example: [Toss Bot](./examples/tossbot.php) (Toss a coin and get the result or roll a dice)\n\n```php\n// Example: Get bot information\n$botInfo = $bot-\u003egetMe();\necho 'Bot Username: ' . $botInfo['result']['username'] . PHP_EOL;\n```\n\n### Sending Messages and Media\n\n#### Sending Text Messages\n\n```php\n// Send a text message\n$chatId = 'YOUR_CHAT_ID';\n$message = 'Hello from PhpGram!';\n$response = $bot-\u003esendMessage($chatId, $message);\n```\n\n#### Sending Photos\n\n```php\n// Send a photo\n$photoPath = 'path/to/photo.jpg';\n$response = $bot-\u003esendPhoto($chatId, $photoPath, ['caption' =\u003e 'Check out this photo!']);\n```\n\n#### Sending Audio\n\n```php\n// Send an audio file\n$audioPath = 'path/to/audio.mp3';\n$response = $bot-\u003esendAudio($chatId, $audioPath, ['caption' =\u003e 'Listen to this audio!']);\n```\n\n#### Sending Documents\n\n```php\n// Send a document\n$documentPath = 'path/to/document.pdf';\n$response = $bot-\u003esendDocument($chatId, $documentPath, ['caption' =\u003e 'Here is your document.']);\n```\n\n#### Sending Videos\n\n```php\n// Send a video\n$videoPath = 'path/to/video.mp4';\n$response = $bot-\u003esendVideo($chatId, $videoPath, ['caption' =\u003e 'Watch this video!']);\n```\n\n#### Sending Animations\n\n```php\n// Send an animation\n$animationPath = 'path/to/animation.gif';\n$response = $bot-\u003esendAnimation($chatId, $animationPath, ['caption' =\u003e 'Enjoy this animation!']);\n```\n\n#### Sending Voice Messages\n\n```php\n// Send a voice message\n$voicePath = 'path/to/voice.ogg';\n$response = $bot-\u003esendVoice($chatId, $voicePath, ['caption' =\u003e 'Listen to this voice message!']);\n```\n\n#### Sending Video Notes\n\n```php\n// Send a video note\n$videoNotePath = 'path/to/video_note.mp4';\n$response = $bot-\u003esendVideoNote($chatId, $videoNotePath);\n```\n\n#### Sending Media Groups\n\n```php\n// Send a media group\n$mediaGroup = [\n    ['type' =\u003e 'photo', 'media' =\u003e 'path/to/photo1.jpg'],\n    ['type' =\u003e 'photo', 'media' =\u003e 'path/to/photo2.jpg'],\n];\n$response = $bot-\u003esendMediaGroup($chatId, $mediaGroup);\n```\n\n#### Sending Locations\n\n```php\n// Send a location\n$response = $bot-\u003esendLocation($chatId, 40.712776, -74.005974); // New York City coordinates\n```\n\n#### Sending Venues\n\n```php\n// Send a venue\n$response = $bot-\u003esendVenue($chatId, 40.712776, -74.005974, 'Venue Name', 'Venue Address');\n```\n\n#### Sending Contacts\n\n```php\n// Send a contact\n$response = $bot-\u003esendContact($chatId, 'PHONE_NUMBER', 'FirstName', ['last_name' =\u003e 'LastName']);\n```\n\n#### Sending Polls\n\n```php\n// Send a poll\n$response = $bot-\u003esendPoll($chatId, 'Your Question?', ['Option 1', 'Option 2']);\n```\n\n#### Sending Dice\n\n```php\n// Send a dice\n$response = $bot-\u003esendDice($chatId);\n```\n\n### Managing Chats and Members\n\n```php\n// Kick a member from a chat\n$userId = 'USER_ID_TO_KICK';\n$response = $bot-\u003ekickChatMember($chatId, $userId);\n\n// Unban a member from a chat\n$response = $bot-\u003eunbanChatMember($chatId, $userId);\n\n// Restrict a member in a chat\n$permissions = ['can_send_messages' =\u003e false];\n$response = $bot-\u003erestrictChatMember($chatId, $userId, $permissions);\n\n// Promote a member to an admin\n$response = $bot-\u003epromoteChatMember($chatId, $userId);\n\n// Set custom title for an admin\n$response = $bot-\u003esetChatAdministratorCustomTitle($chatId, $userId, 'Custom Title');\n```\n\n### Handling Stickers\n\n```php\n// Send a sticker\n$stickerPath = 'path/to/sticker.webp';\n$response = $bot-\u003esendSticker($chatId, $stickerPath);\n\n// Get a sticker set\n$stickerSetName = 'sticker_set_name';\n$response = $bot-\u003egetStickerSet($stickerSetName);\n\n// Upload a sticker file\n$stickerFilePath = 'path/to/sticker.png';\n$response = $bot-\u003euploadStickerFile($userId, $stickerFilePath);\n\n// Create a new sticker set\n$stickerParams = [\n    'name' =\u003e 'sticker_set_name',\n    'title' =\u003e 'Sticker Set Title',\n    'png_sticker' =\u003e 'path/to/sticker.png',\n    'emojis' =\u003e '😀',\n];\n$response = $bot-\u003ecreateNewStickerSet($userId, $stickerParams);\n\n// Add a sticker to a set\n$response = $bot-\u003eaddStickerToSet($userId, 'sticker_set_name', 'path/to/sticker.png', '😀');\n\n// Set sticker position in a set\n$response = $bot-\u003esetStickerPositionInSet('sticker_file_id', 0);\n\n// Delete a sticker from a set\n$response = $bot-\u003edeleteStickerFromSet('sticker_file_id');\n```\n\n### Inline Mode\n\n```php\n// Answer an inline query\n$inlineQueryId = 'INLINE_QUERY_ID';\n$results = [ /* Array of InlineQueryResult objects */ ];\n$response = $bot-\u003eanswerInlineQuery($inlineQueryId, $results);\n```\n\n### Payments\n\n```php\n// Send an invoice\n$invoiceParams = [\n    'title' =\u003e 'Product Name',\n    'description' =\u003e 'Description of the product',\n    'payload' =\u003e 'unique_payload',\n    'provider_token' =\u003e 'PROVIDER_PAYMENT_TOKEN',\n    'start_parameter' =\u003e 'start_param',\n    'currency' =\u003e 'USD',\n    'prices' =\u003e json_encode([ ['label' =\u003e 'Product Price', 'amount' =\u003e 1000] ]),\n];\n$response = $bot-\u003esendInvoice($chatId, $invoiceParams);\n\n// Answer a shipping query\n$shippingQueryId = 'SHIPPING_QUERY_ID';\n$response = $bot-\u003eanswerShippingQuery($shippingQueryId, true);\n\n// Answer a pre-checkout query\n$preCheckoutQueryId = 'PRE_CHECKOUT_QUERY_ID';\n$response = $bot-\u003eanswerPreCheckoutQuery($preCheckoutQueryId, true);\n```\n\n### Games\n\n```php\n// Send a game\n$gameShortName = 'game_short_name';\n$response = $bot-\u003esendGame($chatId, $gameShortName);\n\n// Set game score\n$response = $bot-\u003esetGameScore($userId, 100);\n\n// Get game high scores\n$response = $bot-\u003egetGameHighScores($userId);\n```\n\n### Handling Updates\n\n```php\n// Get updates\n$updates = $bot-\u003egetUpdates();\n\n// Set a webhook\n$response = $bot-\u003esetWebhook('https://yourdomain.com/webhook');\n\n// Delete a webhook\n$response = $bot-\u003edeleteWebhook();\n\n// Get webhook info\n$response = $bot-\u003egetWebhookInfo();\n```\n\n## Contributing\n\nContributions are welcome! Fork the repository, make your changes, and submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/SH20RAJ/phpgram/blob/main/LICENSE) file for details.\n\n---\n\n### Important Links\n\n\u003e https://dev.to/sh20raj/how-to-create-a-telegram-bot-using-php-4hbd\n\n\u003e https://dev.to/sh20raj/phpgram-a-php-library-for-interacting-with-the-telegram-bot-api-3pip\n\n\u003e Video Documentation :- https://www.youtube.com/watch?v=FNnruIqvJDc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh20raj%2Fphpgram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsh20raj%2Fphpgram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh20raj%2Fphpgram/lists"}