I use the IP of a VPN server as a proxy, I wonder why it doesn't work when I use 'https' instead?
Closed this issue · 5 comments
Here's my code:
<?php
require_once 'vendor/autoload.php'; // Include Composer's autoloader
use Stichoza\GoogleTranslate\GoogleTranslate;
// $tr = new GoogleTranslate('fr');
$tr = new GoogleTranslate('fr');
// Set proxy to tcp://localhost:8090
$tr->setOptions([
'proxy' => [
'http' => 'tcp://5.78.95.239'
]
]);
$text = $tr->translate('Hello World!');
echo $text; // Output: en
This code works with 'http'. Why doesn't it work with 'https'? Could I check if it really takes this proxy with 'http' into account? How can I check this?
Where cannot see where you specify http
or https
🤔
Where cannot see where you specify
http
orhttps
🤔
If I use this "'https' => 'tcp://5.78.95.239'" is preferred. It doesn't work and I'm not even 100% sure if it works "'http' => 'tcp://5.78.95.239'"? Although it has translated the text. But how can I check it?
Got it.
The translation URL starts with https://
, so by specifying proxy for http
only, makes no difference. Request is being sent directly without proxy.
You can set proxy for all protocols like this:
$tr->setOptions([
'proxy' => 'tcp://5.78.95.239', // <-- Proxy for all protocols
]);
The issue is with proxy itself, I recommend testing proxy separately by a Guzzle client. In your case:
$client = new GuzzleHttp\Client();
$client->request('GET', 'https://dummyjson.com/products', ['proxy' => 'tcp://5.78.95.239']);
Got it.
The translation URL starts with
https://
, so by specifying proxy forhttp
only, makes no difference. Request is being sent directly without proxy.You can set proxy for all protocols like this:
$tr->setOptions([ 'proxy' => 'tcp://5.78.95.239', // <-- Proxy for all protocols ]);
The issue is with proxy itself, I recommend testing proxy separately by a Guzzle client. In your case:
$client = new GuzzleHttp\Client(); $client->request('GET', 'https://dummyjson.com/products', ['proxy' => 'tcp://5.78.95.239']);
It doesn't work. Can you give me several proxies so that Google doesn't temporarily suspend the translation? I think there will be a large volume of visitors to my site and I won't have enough money to pay for the Google api key. Is there a way to create several 100% working proxies so that Google doesn't temporarily block the translation?