DwzTool.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Azylee.Jsons;
  2. using Azylee.YeahWeb.HttpUtils;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Text;
  8. namespace Azylee.YeahWeb.BaiDuWebAPI.dwz
  9. {
  10. public static class DwzTool
  11. {
  12. /// <summary>
  13. /// 短网址生成接口
  14. /// </summary>
  15. /// <param name="token">由数字和字母组成的32位字符</param>
  16. /// <param name="url">长网址</param>
  17. /// <returns></returns>
  18. public static DwzResponseModel Create(string token,string url )
  19. {
  20. try
  21. {
  22. string address = $"https://dwz.cn/admin/v2/create";
  23. CookieCollection cookie = new CookieCollection();
  24. DwzRequestModel data = new DwzRequestModel();
  25. Dictionary<string, string> header = new Dictionary<string, string>();
  26. data.url = url;
  27. header.Add("Token", token);
  28. string rs = HttpToolPlus.PostJson(address, ref cookie, data, Encoding.UTF8, header);
  29. DwzResponseModel obj = Json.String2Object<DwzResponseModel>(rs);
  30. if (obj != null) return obj;
  31. }
  32. catch { }
  33. return null;
  34. }
  35. }
  36. }