如何使用Telegram bot api阻止后发送消息?

时间:2018-04-18 10:45:17

标签: telegram telegram-bot php-telegram-bot

我创建了一个https://github.com/php-telegram-bot/core/的电报机器人。 Bot位于俄罗斯。出于某种原因,俄罗斯当局阻止了一些电报功能,我的机器人无法向注册用户发送消息。为避免这种情况,我尝试使用代理

$telegram = new Longman\TelegramBot\Telegram('API-key', 'Bot-name');

$data = [

    'chat_id' => 12345678,
    'text' => 'Test message',
];

Longman\TelegramBot\Request::setClient(new \GuzzleHttp\Client([

    'base_uri' => 'https://api.telegram.org',
    'proxy'    => 'socks5://218.248.73.193:1080',
    'verify'   => false,
]));

$result = Longman\TelegramBot\Request::sendMessage($data);

但它会返回Telegram returned an invalid response! Please review your bot name and API key.

如何避免这个问题?提前谢谢!

1 个答案:

答案 0 :(得分:-1)

Longman \ TelegramBot \ Request :: setClient(new \ GuzzleHttp \ Client([

'base_uri' => 'https://api.telegram.org',
'proxy'    => 'socks5://218.248.73.193:1080',
'verify'   => false,
'timeout' =>  10, //*****add this

]));