【发布时间】:2017-10-26 09:42:35
【问题描述】:
我正在尝试实现一个小型 slackbot,我想在其中利用 google 翻译 API,但我很难让它工作。我确实设法运行了一个请求,但在一个成功的请求之后,我不断收到“403 - 超出每日限制”消息。
我正在使用 F#,我的简单代码如下所示:
module Translation =
open Google.Cloud.Translation.V2
let client = TranslationClient.Create()
let detectLanguage text =
let detection = client.DetectLanguage(text)
let res = sprintf "%A %A %A %A" detection.Confidence detection.IsReliable detection.Language detection.Text
res
当我调用“detectLanguage”时,我得到了这个异常:
未处理的异常:Google.GoogleApiException:Google.Apis.Requests.RequestError 超出每日限额 [403] 错误 [ 消息[超出每日限制] 位置[-] 原因[dailyLimitExceeded] 域[usageLimits] ] 在 Google.Apis.Requests.ClientServiceRequest
1.Execute() at Google.Cloud.Translation.V2.TranslationClientImpl.DetectLanguages(IEnumerable1 textItems) 在 Google.Cloud.Translation.V2.TranslationClient.DetectLanguage(字符串文本)
当我检查控制台时,我看不到任何对 API 的请求,所以我认为它可能没有正确配置。我该如何解决这个问题?
我首先在论坛https://groups.google.com/forum/#!topic/google-translate-api/5JHj3RLrH7o 中发布了问题,并得到了一条评论,我需要正确验证。据我了解,.NET 客户端 TranslationClient.Create() 应该使用默认凭据(如果我没有指定任何凭据),这适用于我使用的所有其他谷歌工具。
【问题讨论】:
标签: .net google-cloud-platform google-translate