microsoft translator API

参照文档:https://docs.microsofttranslator.com/text-translate.html

mac osx下用PAW工具,可以模拟get请求,

首先在azure 控制面板上 create一个Cognitive Service

https://portal.azure.com 

要付费的, 需要输入信用卡号,选择一种付费方案,比如先试试即用即付吧。

它的网站说了,All calls to Microsoft Translator Text API require a subscription key to authenticate

然后在all resources 就可以看到自己的语言翻译API的subscription key 了

这个access token只在10分钟内有效,每10分钟您需要拿一个新的,然而10分钟内的多次请求需要用这段时间里的同一个access token,The acces token is valid for 10 minutes. Obtain a new acces token every 10 minutes, and keep using the same access token for repeated requests within these 10 minutes.

代码example看这里 https://github.com/MicrosoftTranslator


这是一个付费的API,有两种付费用户身份验证方式,

1. Using an access token.

2. Using a subscription key directly.

Pass your subscription key(azure控制面板 Manage keys Show access keys ...) as a value in Ocp-Apim-Subscription-Key header included with your request to the Translator API. In this mode, you do not have to call the authentication token service to generate an access token.

在PAW里试验, 

get请求方式,地址 https://api.microsofttranslator.com/V2/Http.svc/Translate

header name填 Ocp-Apim-Subscription-Key , value填subscription key

URL params里填3个值

text : 要翻译的比如 今天天气真不错

from: 源语言比如 zh (zh for chinese)

to: 目标语言比如 en (en for English)

按下按钮发出请求,就可以收到微软服务器的xml格式的回复了

你可能感兴趣的:(microsoft translator API)