这是我第一次使用这种API。而且我以为我正在遵循指示。我在控制台中创建了一个项目并使用REST GET命令
curl https://www.googleapis.com/language/translate/v2?key=AIzaSyCTBfJhbBALXOzV_UgPga-ViBUZbtsWqMU&source=en&target=de&q=Hello%20world&q=My%20name%20is%20Jeff
为什么这不起作用? 它发回了:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: q",
"locationType": "parameter",
"location": "q"
},
{
"domain": "global",
"reason": "required",
"message": "Required parameter: target",
"locationType": "parameter",
"location": "target"
}
],
"code": 400,
"message": "Required parameter: q"
}
}
谢谢。
答案 0 :(得分:1)
对于curl,您需要包含带引号的带有引号的URL。
curl "https://www.googleapis.com/language/translate/v2?key=AIzaSyCTBfJhbBALXOzV_UgPga-ViBUZbtsWqMU&source=en&target=de&q=Hello%20world&q=My%20name%20is%20Jeff"