我使用谷歌翻譯api for Java。
當我試圖讓從代碼轉換我得到了以下錯誤:
服務器返回的HTTP響應代碼:403谷歌翻譯API
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.
我的網址conntection對象定義:
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);
僅在上週發生錯誤。 在此之前,一切工作正常使用相同的代碼
一個403是'forbidden'錯誤。你確定你正在使用API嗎? –
嘿,只在最後一週發生的錯誤 在此之前,一切工作正常,具有相同的代碼 –
它是否在瀏覽器中工作?這是官方的翻譯API網址還是您從網頁界面確定的網址?如果它的後者在任何時候改變/阻止 –