miladnazari/telegram-bot-api

用于Telegram机器人API的简单包

v1.2.8 2018-11-06 08:20 UTC

This package is not auto-updated.

Last update: 2024-10-02 21:32:09 UTC


README

为PHP提供支持多机器人的简单Telegram机器人API

使用composer安装

composer require miladnazari/telegram-bot-api

用法

创建新对象

$api = new \miladnazari\telegramBotApi\api('YOUR-BOT-TOKEN');


//create with more options

$api = new \miladnazari\telegramBotApi\api('YOUR-BOT-TOKEN'[, bool $getResult = true [, int $connectionTimeOut = 10 [, int $responseTimeOut = 50 ]]]);

get me 方法

$res = $api->action('getMe')->shoot();

// return {"ok":true,"result":{"id":598765309,"is_bot":true,"first_name":"G11\ufe0f\u20e3","username":"mnrG1bot"}} in std class

sendMessage 方法

$res = $api->action('sendMessage')
     ->param([
         'chat_id' => 'ID OR USERNAME',
         'text' => 'FIRTS TEXT TO SEND',
     ])
     ->shoot();