Invalid value (400) using google translate api

纵然是瞬间 提交于 2020-12-10 14:26:18

问题


What's wrong with my request?

I have sting in russian: $string = Потенциал, %

I want to translate it to ukrainian with google API:

I urlencode string:

$q = urlencode($string)

And i request google API:

https://www.googleapis.com/language/translate/v2?q=%D0%9F%D0%BE%D1%82%D0%B5%D0%BD%D1%86%D0%B8%D0%B0%D0%BB%2C%20%25&target=ua&source=ru&key=A...

In response I get :

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

What's wrong with my request?


回答1:


Solution was simple. Google has UK letters for ukrainian instead of UA.




回答2:


The target should be uk not ua.I think it will resolve the issue.



来源:https://stackoverflow.com/questions/28570649/invalid-value-400-using-google-translate-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!