rde / php-telegram-connection
Telegram API 连接
v0.4.2
2016-06-01 03:17 UTC
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: 4.*
- rde/php-terminal: *
README
简化 Telegram API 请求
用法
建立连接
use Rde\Telegram\Connection; // 成功建立連線後, $conn->me 會存放此 bot 的 id 資料 $conn = new Connection($token);
$token获取方式请参考 Telegram Bot Token$conn->me结构请参考 Telegram Bot API getMe
发送消息
use Rde\Telegram\Structure; $payload = new Structure(array( 'chat_id' => $int )); $payload->{'text'} = 'some text string'; $telegram_response = $conn->sendMessage($payload);
使用 post
$conn->method('POST'); //$conn->sendMessage($payload);
命令行工具
bot api 转发
$ ./bot <token|bot_name> <method> [payload]
使用 post
$ METHOD=POST ./bot <token|bot_name> <method> [payload]
发送消息
$ ./send <token|bot_name> <chat_id> 'your text'