PHP code example of ericgu178 / telegram-api
1. Go to this page and download the library: Download ericgu178/telegram-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ericgu178 / telegram-api example snippets
use TelgramApi/Telegram
$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 数据 去群组查看
$res = $telegram->Message->sendPhoto(string $url,array $ext = []); // $ext 其他参数
var_dump($res);
$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);
$url = '网络地址 mp3 m4a 类型'
$res = $telegram->Message->sendAudio(string $url,$ext); // $ext 其他参数
var_dump($res);