./vendor/bin/phpunit
PHPUnit 4.8.24 by Sebastian Bergmann and contributors.
......EEEEEEE.
Time: 2.93 seconds, Memory: 6.00Mb
There were 7 errors:
1) Stichoza\GoogleTranslate\Tests\LanguageDetectionTest::testSingleWord
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:299
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:175
/home/limon/www/google-translate-php/tests/LanguageDetectionTest.php:16
2) Stichoza\GoogleTranslate\Tests\LanguageDetectionTest::testSingleSentence
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:299
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:175
/home/limon/www/google-translate-php/tests/LanguageDetectionTest.php:25
3) Stichoza\GoogleTranslate\Tests\LanguageDetectionTest::testMultipleSentence
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:299
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:175
/home/limon/www/google-translate-php/tests/LanguageDetectionTest.php:34
4) Stichoza\GoogleTranslate\Tests\LanguageDetectionTest::testStaticAndNonstaticDetection
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:299
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:175
/home/limon/www/google-translate-php/tests/LanguageDetectionTest.php:43
5) Stichoza\GoogleTranslate\Tests\TranslationTest::testTranslationEquality
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:299
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:175
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:395
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:145
/home/limon/www/google-translate-php/tests/TranslationTest.php:16
6) Stichoza\GoogleTranslate\Tests\TranslationTest::testArrayTranslation
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:299
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:175
/home/limon/www/google-translate-php/tests/TranslationTest.php:26
7) Stichoza\GoogleTranslate\Tests\TranslationTest::testRawResponse
ErrorException: Client error: `POST http://translate.google.com/translate_a/t` resulted in a `403 Forbidden` response:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, w (truncated...)
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:262
/home/limon/www/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php:185
/home/limon/www/google-translate-php/tests/TranslationTest.php:44
here is PHP test:
http://www.liuxiatool.com/t.php
The same problem. Is there some guy has any idear.
Thank you guys for your contribution. You rock!
OK. This is what i changed based on code from @helen5106. Don’t know how or where @helen5106 got the changes from, Just refactored the stichoza code based on @helen5106 code: In the main TranslateClient (/vendor/stichoza/google-translate-php/src/Stichoza/GoogleTranslate/TranslateClient.php) //lines 52-80 /** * @var array URL Parameters / private $urlParams = [ ‘client’ => ‘webapp’,//CHANGED ***** ‘sl’ => null, // Source language ‘tl’ => null, // Target language ‘hl’ => ‘en’, ‘dt’ => ‘at’, //ADDED ****** //‘text’ => null, // String to translate // REMOVED****** changed to q last line ‘ie’ => ‘UTF-8’, // Input encoding ‘oe’ => ‘UTF-8’, // Output encoding //‘multires’ => 1, // ??? // REMOVED****** ‘otf’ => 0, // SHOULD IT BE CHANGED TO 2 ???****** //‘pc’ => 1, // REMOVED****** //‘trs’ => 1, // REMOVED****** ‘ssel’ => 0, ‘tsel’ => 0, ‘kc’ => 1, // ADDED****** //‘sc’ => 1, // REMOVED****** ‘tk’ => null, ‘q’ => null, // String to translate ADDED****** changed text to q ];
and in GoogleTokenGenerator (//vendor/stichoza/google-translate-php/src/Stichoza/GoogleTranslate/Tokens/GoogleTokenGenerator.php)
line 38 private function TL($a) { $b = $this->generateB(); // REMOVED****** //REPLACED WITH : $tkk = explode(‘.’, $this->TKK()); $b = $tkk[0];
private function generateB() //FUNCTION NOW REDUNDANT******
Any fix? I’ve done
composer updatebut it gives meand the issue still are 😦
I’ve got the same problem. We’re counting on you guy…