As you know, telegrams were blocked in Russia and this caused difficulties in working with the bot. Can I add a proxy to the core when I request it?
I can edit it only in files libary or i can
Request::setClient(new \GuzzleHttp\Client([
'base_uri' => 'https://api.telegram.org',
'proxy' => 'http://proxy',
]));
?
if i have proxy with login and password, structure of string like this:
http://login:password@ip:port ?
...
$telegram = new Telegram($apiKey, $botName);
Request::setClient(new \GuzzleHttp\Client([
'base_uri' => 'https://api.telegram.org',
'proxy' => 'http://111.111.111.111:1080',
]));
...
if i have proxy with login and password, structure of string like this:
http://login:password@ip:port ?
Yes
Thanks
You shouldn't edit it inside library, put the code I linked into your hook script /before handling updates.
As @jacklul already mentioned, just set the proxy client before handling the request.
Here is an example for using a local Tor proxy with SOCKS5:
$telegram = new Telegram(...);
...
Request::setClient(new Client([
'base_uri' => 'https://api.telegram.org',
'proxy' => 'socks5://127.0.0.1:9050',
]));
...
$telegram->handle();
set.php:
try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
$telegram = Request::setClient(new \GuzzleHttp\Client([ 'proxy' => 'socks5://alex:[email protected]:8088',]));
// Set webhook
$result = $telegram->setWebhook($hook_url);
// Uncomment to use certificate
//$result = $telegram->setWebhook($hook_url, ['certificate' => $path_certificate]);
...
PHP Fatal error: Uncaught Error: Class 'Request' not found in var/www/help.xxx.net/xxx/telegram/set.php:12
How to enable it right?
@kirush0280
Request class firstRequest::setClient call to $telegram variableThank you. It works.
Also when your DNS traffic is spoofed you should to use 'proxy' => 'socks5h:// against socks5:// whithout h
Hi! @akalongman would you please tell what kind of Request it is, from which library?
@timurkayzer
\Longman\TelegramBot\Request
thanks it worked like a charm!
Most helpful comment
As @jacklul already mentioned, just set the proxy client before handling the request.
Here is an example for using a local Tor proxy with SOCKS5: