Stichoza / google-translate-php

🔤 Free Google Translate API PHP Package. Translates totally free of charge.
MIT License
1.82k stars 383 forks source link

version 4.0 no longer working #117

Closed kamyargerami closed 5 years ago

kamyargerami commented 5 years ago

hi i get this error today from the lumen

Client error: POST https://translate.google.com/translate_a/single?client=t&hl=en&dt=t&dt=bd&dt=at&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&sl=en&tl=fa&ie=UTF-8&oe=UTF-8&multires=1&otf=0&pc=1&trs=1&ssel=0&tsel=0&kc=1&tk=725373.860675 resulted in a 400 Bad Request response: <!DOCTYPE html><meta name=viewport content="initial-scale=1, minimum-scale=1, width=de (truncated...)

and it's no longer working

yanglongji commented 5 years ago

same with me

shahzad-ahmad commented 5 years ago

Anybody can provide quick help here?

MuscledGeek commented 5 years ago

I used yesterday and it's working. Maybe you are encounter a ban problem. I recommend you use the proxies option:

$tr = new GoogleTranslate($target, $source, [ 'timeout' => 10, 'proxy' => [ 'http' => 'tcp://0.0.0.0:8080', 'http' => 'tcp://0.0.0.0:3123'//..add more if you wish ], 'headers' => [ 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36' ] ]); return $tr->translate($text);

Hope this help

frzsombor commented 5 years ago

@MuscledGeek

[...] 'proxy' => [ 'http' => 'tcp://0.0.0.0:8080', 'http' => 'tcp://0.0.0.0:3123'//..add more if you wish ], [...]

This is WRONG, this is NOT how you set up proxies. Declaring an array like this is not even valid in PHP (you have a duplicate array key for 'http'). Please follow the example on the main page.

Also, this issue is a duplicate of #112 and that bug has been fixed in #109 (version v4.0.2). Make sure you are using the latest version of this library.

I can confirm that the latest version is working right now.