zafarjonovich / php-helpers
该软件包最新版本(0.0.1)没有提供许可证信息。
PHP 辅助工具
0.0.1
2021-08-02 13:46 UTC
Requires
- php: >=5.6
README
Assalomu aleykum. 这些组件将帮助您在自己的项目中与Telegram机器人API进行交互。使用非常简单。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令
composer require zafarjonovich/telegram
或将以下内容添加到您的 composer.json
文件的 require 部分中。
"zafarjonovich/telegram": "*"
使用方法
可以按照以下方式使用 Telegram机器人API 中的所有方法
<?php require_once 'vendor/autoload.php'; $bot_token = '1111111:AAABBBBCCCDDDDEEEERRRRTTTT'; $telegram = new \zafarjonovich\Telegram\BotApi($bot_token); $telegram->query('sendMessage',[ 'chat_id' => 1122, 'text' => 'Hello world!' ]); $telegram->query('sendPhoto',[ 'chat_id' => 1122, 'photo' => 'photo_url' ]); ?>
已编写了多个Telegram方法。机器人API方法中所需的参数作为处理器方法中的参数给出,并将扩展添加到可选字段中。
编写的方法
sendMessage, deleteMessage, getChatMember, getChat, exportChatInviteLink, editMessageText, answerCallback, forwardMessage, sendPhoto, sendVideo, sendContact, sendDocument, sendLocation, getMe, getWebHookInfo, getUpdates
使用编写的方法
<?php require_once 'vendor/autoload.php'; $bot_token = '1111111:AAABBBBCCCDDDDEEEERRRRTTTT'; $telegram = new \zafarjonovich\Telegram\BotApi($bot_token); $telegram->sendMessage($chat_id,$text); $telegram->sendMessage($chat_id,$text,[ 'parse_mode' => 'markdown' ]); $telegram->sendPhoto($chat_id,$photo,[ 'caption' => 'Hello world!' ]) ?>