-
-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error 403 Forbidden #32
Comments
Finally, its working again, so I suppose that was an error from google maybe? |
Yup, I guess it was Google's problem or maybe some network related. Here is a list of exceptions that you might get. You can wrap your code in a try-catch block to handle this kind of exceptions. |
Could it be that google has banned or restricted my ip? |
It is not working for me. I think they have changed the URL from http://translate.google.com/translate_a/t to https://translate.google.com/#[lang_from]/[lang_to]/[text_to_translate] |
It's not working for me either, and I've just tried this library. I guess something changed. I wasn't able to fix it yet, I've been playing with the query params. |
I run tests several times and they fail randomly.
and so on. It's weird 😒 |
I'll push a dummy commit to see what will travis get. |
Google just updated the API to add a
|
I get the same error. Is there some solutions? |
I confirm it is the English to French |
@tehmaestro I got the same value |
Yes i am facing the same problm..its worked properly yesterday but from today morning...it's giving the same problem....wat's the issue |
@tehmaestro I think it also depends on something else. Did you try to use different browsers? |
EDIT: Actually no, there are the same values, regardless of the browser or computer. It might depend on the browser version though or operating system, I think. |
So what should we do now? Big trouble... |
I might be wrong, but as I see the |
I copied the url from network log and it works from any browser an even from HTTP request testers. In addition to |
Here are my findings. The part which generates the var QL = function(a) {
return function() {
return a
}
}
, RL = function(a, b) {
for (var c = 0; c < b.length - 2; c += 3) {
var d = b.charAt(c + 2)
, d = d >= t ? d.charCodeAt(0) - 87 : Number(d)
, d = b.charAt(c + 1) == Tb ? a >>> d : a << d;
a = b.charAt(c) == Tb ? a + d & 4294967295 : a ^ d
}
return a
}
, SL = null
, TL = function(a) {
var b;
if (null === SL) {
var c = QL(String.fromCharCode(84));
b = QL(String.fromCharCode(75));
c = [c(), c()];
c[1] = b();
SL = Number(window[c.join(b())]) || 0
}
b = SL;
var d = QL(String.fromCharCode(116))
, c = QL(String.fromCharCode(107))
, d = [d(), d()];
d[1] = c();
for (var c = cb + d.join(k) +
mf, d = [], e = 0, f = 0; f < a.length; f++) {
var g = a.charCodeAt(f);
128 > g ? d[e++] = g : (2048 > g ? d[e++] = g >> 6 | 192 : (55296 == (g & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (g = 65536 + ((g & 1023) << 10) + (a.charCodeAt(++f) & 1023),
d[e++] = g >> 18 | 240,
d[e++] = g >> 12 & 63 | 128) : d[e++] = g >> 12 | 224,
d[e++] = g >> 6 & 63 | 128),
d[e++] = g & 63 | 128)
}
a = b || 0;
for (e = 0; e < d.length; e++)
a += d[e],
a = RL(a, Vb);
a = RL(a, Ub);
0 > a && (a = (a & 2147483647) + 2147483648);
a %= 1E6;
return c + (a.toString() + dd + (a ^ b))
} So, some stuff I discovered. For c is '&tk=' string
dd is '.' string That would leave And then there's
I think this is the important part:
So, for each number in Also, |
same issue here. |
@tehmaestro Nicely done! I have also tried the same thing but I was unable to find the value of the constant. It's really nice that you can do it! |
I have finished this issue. http://www.liuxiatool.com/t.php?tk=L function shr32($x, $bits)
{
if($bits <= 0){
return $x;
}
if($bits >= 32){
return 0;
}
$bin = decbin($x);
$l = strlen($bin);
if($l > 32){
$bin = substr($bin, $l - 32, 32);
}elseif($l < 32){
$bin = str_pad($bin, 32, '0', STR_PAD_LEFT);
}
return bindec(str_pad(substr($bin, 0, 32 - $bits), 32, '0', STR_PAD_LEFT));
}
function charCodeAt($str, $index)
{
$char = mb_substr($str, $index, 1, 'UTF-8');
if (mb_check_encoding($char, 'UTF-8'))
{
$ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8');
return hexdec(bin2hex($ret));
}
else
{
return null;
}
}
function RL($a, $b)
{
for($c = 0; $c < strlen($b) - 2; $c +=3) {
$d = $b{$c+2};
$d = $d >= 'a' ? charCodeAt($d,0) - 87 : intval($d);
$d = $b{$c+1} == '+' ? shr32($a, $d) : $a << $d;
$a = $b{$c} == '+' ? ($a + $d & 4294967295) : $a ^ $d;
}
return $a;
}
function TL( $a )
{
$b = 402890;
for ($d = array(), $e = 0, $f = 0; $f < strlen($a); $f++) {
$g = charCodeAt($a, $f);
if ( 128 > $g ) {
$d[$e++] = $g;
} else {
if ( 2048 > $g ) {
$d[$e++] = $g >> 6 | 192;
} else {
if ( 55296 == ($g & 64512) && $f + 1 < strlen($a) && 56320 == (charCodeAt($a, $f + 1) & 64512) ) {
$g = 65536 + (($g & 1023) << 10) + (charCodeAt($a, ++$f) & 1023);
$d[$e++] = $g >> 18 | 240;
$d[$e++] = $g >> 12 & 63 | 128;
} else {
$d[$e++] = $g >> 12 | 224;
$d[$e++] = $g >> 6 & 63 | 128;
}
}
$d[$e++] = $g & 63 | 128;
}
}
$a = $b;
for ($e = 0; $e < count($d); $e++) {
$a += $d[$e];
$a = RL($a, '+-a^+6');
}
$a = RL($a, "+-3^+b+-f");
if (0 > $a) $a = ($a & 2147483647) + 2147483648;
$a %= pow(10, 6);
return sprintf('%d.%d', $a, $a ^ $b);
}
$tk = (isset($_GET['tk']) && !empty($_GET['tk'])) ? $_GET['tk'] : 'love';
echo $tk . "=". TL($tk); |
Wow, congrats. I can confirm it works! |
@helen5106 wow that's a great work 👍 But I still get 403 errors :( @tehmaestro How do you guys tested this token works? |
@helen5106 Awesome! You save my life! |
I just added the functions written above in your class, and added the
Of course, this will not work when |
@tehmaestro It would be nice if someone can also figure out how to generate TL with an array. I really need it. |
@tehmaestro Great! I'll make some preparation changes to the codebase. May I ask you to send me a pull request after I'm done with that changes? |
@helen5106 your code works to english. But if the text is UTF-8 chars, it will get the same error. Maybe need some decode. I will try to do this test. |
I've fixed the script so it works with UTF-8. I will be sending a pull request next week, just as an example. |
I think i'm doing the same thing only difference i do it in PHP instead of Javascript, scraping codes directly from the Google Translate page see the code that i posted above: ` /**
|
@joomlajoe OK, sorry! I didn't read your code carefully. let url = "https://translate.google.com"
return WinJS.xhr({
url: url,
responseType: "text"
}).then(response => {
return response.response
})
.then(body => {
const startStr = 'TKK=eval(';
const endStr = ');WEB_TRANSLATION_PATH=';
const startI = body.indexOf(startStr) + startStr.length;
const endI = body.indexOf(endStr);
const tkkEval = body.substring(startI, endI);
const x = eval(eval(tkkEval));
return x;
}) |
It's working perfect (with grabbing TKK from google). |
Hi @quanglam2807 it's still working fine with the usual static values |
Source Language:zh-CN tk value is wrong , the right result |
@clover2008 Why do you want to translate from zh-CN to zh-CN? Also, could you please describe exactly what is wrong? |
Did you test with the library itself? Also, I don't think that there is any support for simplified chinese at the moment. |
I know you want to translate chinese pinyin to chinese words. pls change this param: t?client=webapp to; single?client=t http://www.liuxiatool.com/t.php?sl=zh-CN&tl=zh-CN&q=tamen&p=2&tijioao=submit |
Thanks to the help of all you guys I was able to make a C++ version of the token generation code (dropped unicode tho, because of lazyness)
|
Hi there :) Thanks to this issue, I came up with a JavaScript module that generates the |
Great work @matheuss ! |
@Skylion007 you can find here the implemetation in Java: http://pastebin.com/G4TJJFNd |
Hi, I also wrote a Python library that uses the Google translate. https://github.com/MrS0m30n3/google-translate Thank you all for your amazing work! |
@quanglam2807@lollita Thanks! |
@helen5106 Thank you man good job |
@helen5106 very good. I expect you improve more and more. |
I made this for python and used php of tastemylife.com
You can use it in terminal or somewhat as : |
…ere](Stichoza/google-translate-php#32). If I finish development than I'll change formal google api
Hello! Today it's not working again for me. Does Google updated TK generation algorithm? |
Just tested.... it's working for me |
Regardless of ip, it stopped working on all projects, both new and those where nothing has changed for 3 years. https://translate.google.ru/translate_a/single?client=t&sl=ru&tl=en&hl=en&dt=t&ie=UTF-8&oe=UTF-8&multires=1&otf=0&pc=1&trs=1&ssel=0&tsel=0&sc=1&tk=803532.684373&q=память): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden |
@feokano first of all open a new issue given that this one has been closed. |
@feokano I can confirm that it's STILL WORKING. There was an update by Google around 23rd Jul 2019, but this project has been updated and working correctly. Please make sure you are using the latest version (v4.0.2 as of now) and use proxies properly to make sure Google doesn't block you. If you are still having problems right now, I'm pretty sure it's not caused by this repo. |
Yes, sorry. |
hi @helen5106
detail
I use Stichoza\GoogleTranslate\Tokens\GoogleTokenGenerator to generate token
everything works fine but when i encode the query and use multi query like this demo, the gen token output is not correct anymore so, is the gen token function giving the error? |
exam code err
|
sorry,it seems have some bugs.
***@***.***
From: taiviemthoi
Date: 2021-06-16 16:28
To: Stichoza/google-translate-php
CC: shixiangjun888; Comment
Subject: Re: [Stichoza/google-translate-php] Error 403 Forbidden (#32)
hi @helen5106
I am using this endpoint
https://translate.googleapis.com/translate_a/t?anno=3&client=tee&format=html
detail
curl 'https://translate.googleapis.com/translate_a/t?anno=3&client=tee&format=html&v=1.0&key&sl=auto&tl=vi&tc=2&sr=1&tk=740634.884324&mode=1' \
-H 'authority: translate.googleapis.com' \
-H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'accept: */*' \
-H 'sec-fetch-site: cross-site' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'accept-language: en-US,en;q=0.9,fr-FR;q=0.8,fr;q=0.7,sw-TZ;q=0.6,sw;q=0.5,es;q=0.4,de;q=0.3' \
--data-raw 'q=i love you' \
--compressed
I use Stichoza\GoogleTranslate\Tokens\GoogleTokenGenerator to generate token
generateToken("en", "vi", "i love you") => token: 740634.884324
everything works fine
but when i encode the query and use multi query like this demo, the gen token output is not correct anymore
so, is the gen token function giving the error?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Till yesterday everything was working perfectly with your translator, but today I'm getting the next error:
Fatal error: Uncaught exception 'ErrorException' with message 'Client error response [url] http://translate.google.com/translate_a/t [status code] 403 [reason phrase] Forbidden'
And the stack trace says that comes from lines 215, 247 and 143 of the method TranslateClient.php.
Do you suspect which is the problem?
The text was updated successfully, but these errors were encountered: