我正在使用google translate api for Java
当我试图从代码翻译时,我得到以下错误:
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.
我的网址连接对象是定义:
urlConn = url.openConnection();
urlConn.addRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
有什么建议吗?
API使用代码:
translate.translate(text, Language.ENGLISH,
Language.PORTUGUESE);
仅在上周发生错误。 在此之前,一切正常,使用相同的代码
答案 0 :(得分:3)
尝试使用更新后的API(您需要一个密钥):http://hayageek.com/google-translate-api-tutorial/#java-example
答案 1 :(得分:1)