微软Bing翻译API的使用

  • 首先要有微软账号,比如hotmail什么的
  • https://datamarket.azure.com/developer/applications

订阅翻译服务

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




注册自己的注册应用程序

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



  • 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

    {
      "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

    星期一

其他翻译API :

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

你可能感兴趣的:(微软Bing翻译API的使用)