Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paranoiasystem/telegrambot-php-library
TelegramBot is an unofficial library for use the Telegram APIs for bot
https://github.com/paranoiasystem/telegrambot-php-library
Last synced: about 2 months ago
JSON representation
TelegramBot is an unofficial library for use the Telegram APIs for bot
- Host: GitHub
- URL: https://github.com/paranoiasystem/telegrambot-php-library
- Owner: paranoiasystem
- License: gpl-2.0
- Created: 2015-07-25T13:06:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-18T18:59:17.000Z (over 9 years ago)
- Last Synced: 2024-04-22T06:21:05.736Z (9 months ago)
- Language: PHP
- Size: 252 KB
- Stars: 9
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TelegramBot-PHP-library
[![Travis](https://img.shields.io/travis/paranoiasystem/TelegramBot-PHP-library.svg?style=flat-square)](https://travis-ci.org/paranoiasystem/TelegramBot-PHP-library)
[![Packagist](https://img.shields.io/packagist/v/paranoiasystem/telegrambot-php-library.svg?style=flat-square)](https://packagist.org/packages/paranoiasystem/telegrambot-php-library)
[![Total Downloads](https://img.shields.io/packagist/dt/paranoiasystem/telegrambot-php-library.svg?style=flat-square)](https://packagist.org/packages/paranoiasystem/telegrambot-php-library)
[![GitHub license](https://img.shields.io/badge/license-GPLv2-blue.svg?style=flat-square)](LICENSE)TelegramBot is an unofficial library in PHP for use the [Telegram APIs for bot](https://core.telegram.org/bots/api)
## Install
Via Composer
``` bash
$ composer require paranoiasystem/telegrambot-php-library
```## Usage
Send Message
``` php
sendMessage('chat_id', 'text');
```Send Photo
``` php
sendPhoto('chat_id', 'path_to_photo');//or
$bot->sendPhoto('chat_id', array('file_id' => 'file_id_value'));
```## Bot Example
Set WebHook
``` php
setWebhook("https://url.to/hook.php"); //only httpsif($response->description == "Webhook was set")
echo "Ok! The bot is ready!";
else{
echo "Ops! Error
";
print_r($response);
}
?>
```BotCore (hook.php)
``` php
hook();$comand = $response->message->text;
if(substr($comand, 0, strlen("/echo")) === "/echo")
$bot->sendMessage($response->message->chat->id, str_replace("/echo", "", $comand));if(substr($comand, 0, strlen("/img")) === "/img")
$bot->sendPhoto($response->message->chat->id, 'path_to_photo');
?>
```