Reputation: 624
i'm using google translate api for Java.
When i'm tried to get translate from code i got the following error:
java.io.IOException: Server returned HTTP response code: 403 for URL: http://translate.google.com.br/translate_a/single?client=t&sl=auto&tl=pt&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=1&rom=1&ssel=0&tsel=3&kc=1&tk=620730|996163&q=Try%20mWinMgr%20=%20(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);int%20displayWidth%20=%20mWinMgr.getDefaultDisplay().getWidth();where%20context%20is%20Context%20instance.By%20default,%20the%20FrameLayout%20in%20which%20your%20layout%20is%20kept,%20fills%20the%20whole%20display%20horizontally%20(vertically%20you%20can%20have%20status%20bar).%20So%20you%20can%20set%20the%20maximum%20possible%20width%20by%20using%20android:layout_width="fill_parent"%20correctly.
My url conntection object is define:
urlConn = url.openConnection();
urlConn.addRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
Any suggestions please?
API Using code:
translate.translate(text, Language.ENGLISH,
Language.PORTUGUESE);
An error occurred only in the last week. Before that everything works fine with the same code
Upvotes: 3
Views: 5000
Reputation: 398
Try this, using the updated API (you need a key): http://hayageek.com/google-translate-api-tutorial/#java-example
Upvotes: 3
Reputation: 6015
It looks like the URL being generated is malformed. The library you are using is also an out-of-date library from the Google Code archive. It likely was working by coincidence, but you just now exposed a problem.
Please use the current version of the Translate API Client, available here.
Upvotes: 1