gpt4 book ai didi

google-translate - 通过 curl 测试谷歌翻译 API

转载 作者:行者123 更新时间:2023-12-02 17:28:25 40 4
gpt4 key购买 nike

我正在通过 curl 测试 Google Translate API,它一直在询问参数 q,而它已经存在于 URL 中 (q=Hello%20World)。为什么 Google Translate API 会返回此错误?

curl https://www.googleapis.com/language/translate/v2?key= &source=en&target=de&q=Hello%20World

[1] 16848
[2] 16849
[3] 16850
[2]- Done source=en
[3]+ Done target=de
foo:~ foo$ {
"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"
}
}

帮忙吗?

最佳答案

您必须用双引号将整个 URL 括起来,例如:

curl "https://www.googleapis.com/language/translate/v2?key=&source=en&target=de&q=Hello%20World"

否则,您的 shell 将在实际执行 curl 之前解释那些 & 字符;这就是为什么您会在开头看到所有这些行:

[1] 16848
[2] 16849
[3] 16850
[2]- Done source=en
[3]+ Done target=de

关于google-translate - 通过 curl 测试谷歌翻译 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36676820/

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