微软Bing翻译API的使用

来源:互联网 发布:java 枚举接口 编辑:程序博客网 时间:2024/05/02 02:56
  • 首先要有微软账号,比如hotmail什么的
  • https://datamarket.azure.com/developer/applications

订阅翻译服务

https://datamarket.azure.com/dataset/bing/microsofttranslator

1.jpg



注册自己的注册应用程序

https://datamarket.azure.com/developer/applications

2.jpg


  • POST
    Content-Type: application/x-www-form-urlencoded
    https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    grant_type=client_credentials&client_id=active_gaowei&client_secret=secretsecretsecretsecret&scope=http://api.microsofttranslator.com
    3.jpg
    {
      "token_type": "http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0",
      "access_token": "http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=active_gaowei&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fapi.microsofttranslator.com&ExpiresOn=1437443770&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=j69yYSrpz%2bB%2fbLUUSaGAjrxvZxLijAJMGDDm1fRJuog%3d",
      "expires_in": "600",
      "scope": "http://api.microsofttranslator.com"
    }

    注意获得的token密匙是有有效时间的,为600秒即10分钟。 超过10分钟后密匙失效。


  • GET
    Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=active_gaowei&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fapi.microsofttranslator.com&ExpiresOn=1437443770&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=j69yYSrpz%2bB%2fbLUUSaGAjrxvZxLijAJMGDDm1fRJuog%3d
    http://api.microsofttranslator.com/v2/Http.svc/Translate?text=monday&from=en&to=zh
    4.jpg
    <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">星期一</string>

其他翻译API :

http://apistore.baidu.com/astore/classificationservicelist/38.html

0 0