全部产品
云市场

.NET使用示例

更新时间:2019-08-30 17:58:00

.NET使用示例

需要阿里云.NET SDK

  1. String accessKeyId = "XXXXXXX";
  2. String accessKeySecret = "XXXXXXXXXXXX";
  3. DefaultProfile.AddEndpoint("cn-shanghai", "cn-shanghai", "Nlp", "nlp.cn-shanghai.aliyuncs.com");
  4. IClientProfile profile = DefaultProfile.GetProfile("cn-shanghai", accessKeyId, accessKeySecret);
  5. IAcsClient client = new DefaultAcsClient(profile);
  6. String postBody = "{\n"
  7. + " \"text\": \"真丝韩都衣舍连衣裙\",\n"
  8. + "}";
  9. CommonRequest request = new CommonRequest();
  10. request.Domain = "nlp.cn-shanghai.aliyuncs.com";
  11. request.UriPattern = "/nlp/api/wordpos/general";
  12. request.Method = MethodType.POST;
  13. request.SetContent(System.Text.Encoding.Default.GetBytes(postBody),"utf-8",FormatType.JSON);
  14. request.AddHeadParameters("x-acs-signature-method", "HMAC-SHA1");
  15. request.AddHeadParameters("x-acs-signature-nonce", System.Guid.NewGuid().ToString());
  16. request.Action = "None";
  17. request.Version = "2018-04-08";
  18. CommonResponse response = client.GetCommonResponse(request);
  19. Console.WriteLine(response.Data);