ericgu178 / telegram-api
该软件包最新版本(0.3)没有提供许可证信息。
电报群机器人API
0.3
2021-04-20 07:05 UTC
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2024-09-20 15:02:18 UTC
README
TelegramApi
清单
安装
使用以下命令安装
composer require ericgu178/telegram-api
在PHP文件中使用
use TelgramApi/Telegram
关于
这是我自用的电报API封装代码,目前只涉及Message API的发送,并未完全适配所有电报API。如果有需要或者其他bug,我会进行修改。其他功能也欢迎在基础上push代码,我也会继续完善。
使用
目前适用于机器人(未测试其他)需要给予管理权限。
$config = [ 'api_id' => '', // api id 'api_hash' => '', // api hash 'botToken' => '', // @EricGU178Bot 'chat_id' => '@wechatGroupQrCode', 'proxy' => '' //代理 ]; $telegram = Telegram::openPlatform($config); $res = $telegram->Message->sendMessage($text = 'Hello World'); var_dump($res); // json 数据 去群组查看
接口
目前只有 /lib/OpenPlatform/Message/ 中的三个方法:sendPhoto, sendMessage, sendGroupMedia, sendAudio。
消息
使用 sendPhoto
$res = $telegram->Message->sendPhoto(string $url,array $ext = []); // $ext 其他参数 var_dump($res);
使用 sendGroupMedia
sendAudio
$res = $telegram->Message->sendGroupMedia([ [ 'type' => 'photo', 'media' => 'https://ww1.sinaimg.cn/large/6d28b716ly1goswssp7huj20s311cq87.jpg', 'caption' => '微博' ], [ 'type' => 'photo', 'media' => 'https://ww1.sinaimg.cn/large/6d28b716ly1goswssp7huj20s311cq87.jpg', 'caption' => 'aaaa' ], ]); // $ext 其他参数 var_dump($res);
使用 sendAudio
$url = '网络地址 mp3 m4a 类型' $res = $telegram->Message->sendAudio(string $url,$ext); // $ext 其他参数 var_dump($res);