gpt4 book ai didi

java - 服务器返回 HTTP 响应代码 : 403 for URL Google Translate API

转载 作者:行者123 更新时间:2023-12-02 04:16:54 25 4
gpt4 key购买 nike

我正在使用适用于 Java 的谷歌翻译 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.

我的 url 连接对象已定义:

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);

仅在上周发生了错误。在此之前,使用相同的代码一切正常

最佳答案

尝试使用更新的 API(您需要 key ):http://hayageek.com/google-translate-api-tutorial/#java-example

关于java - 服务器返回 HTTP 响应代码 : 403 for URL Google Translate API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35182285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com