![](/img/trans.png)
[英]Using the Azure Microsoft Translator API with PHP and cURL
[英]Translation using Microsoft Translator API Timeout
我愿意使用Microsoft Translator API以3种不同的语言翻译特定的文本。 我配置了它,很显然,我得到的链接应该使我无法翻译:
https://api.datamarket.azure.com/Data.ashx/Bing/MicrosoftTranslator/v1/Translate?Text=%27Osteopathy%27&From=%27en%27&To=%27nl%27&$format=Raw&$top=100
我也在终端中使用curl进行了尝试,并获得了授权,但是似乎没有响应发送:
$ curl -H 'Authorization: Basic ***my authorization_key encoded in base64***' 'https://api.datamarket.azure.com/Data.ashx/Bing /MicrosoftTranslator/v1/Translate?Text=%27Osteopathy+for+Babies%27&From=%27en%27&To=%27nl%27&$format=Raw&$top=100'
没有来自Microsoft Translator的答复。 它只是超时。
几周前,同一段代码起作用了。
可能是什么原因? 如何解决这个问题?
我尝试了与您相同的请求,但确实从服务器返回了响应,但这是403禁止的。 我无法推测为什么代码不再起作用,但是如果您还获得了403,则可能值得刷新密钥,它可能已经过期。 否则,API的行为将发生重大变化,没有任何官方文档很难说。
但是,您可以尝试使用Microsoft Cognitive Services API,大约需要5分钟来设置。 您将需要使用OAuth承载令牌,而不是基本身份验证,但这还是更加安全。
设置文档https://www.microsoft.com/zh-cn/translator/getstarted.aspx
获取令牌http://docs.microsofttranslator.com/oauth-token.html
以及github上MicrosoftTranslator / HTTP-Code-Samples下的一些代码示例
Azure数据市场已关闭-此处有有关迁移到Azure的更多信息: https ://translatorbusiness.uservoice.com/knowledgebase/articles/1078534-action-required-before-april-30-2017-microsoft-t
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.