H5stHack.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using dodohold.core;
  2. using Sayaka.Common;
  3. namespace molilian.core
  4. {
  5. public partial class JdUnionPlus
  6. {
  7. public async Task<string> H5stHack(dynamic querystring, CancellationToken cancellationToken)
  8. {
  9. string body = string.Empty;
  10. string useragent = _account.user_agent;
  11. if (string.IsNullOrEmpty(useragent)) useragent = ProviderFakeUserAgent.RandomComputer;
  12. var args = new
  13. {
  14. version = _config.jd_h5st_sign_version,
  15. body = querystring,
  16. pin = _account.pin,
  17. ua = _account.user_agent,
  18. h5st = _account.h5st,
  19. };
  20. try
  21. {
  22. string data = args.Convert2Json();
  23. string url = _config.jd_h5st_sign_url;
  24. if (string.IsNullOrEmpty(url)) url = "http://localhost:3001/h5st";
  25. #if DEBUG
  26. url = "http://bjapi.molilian.com:3001/h5st";
  27. #endif
  28. WebClientUtility client = new WebClientUtility();
  29. client.SetContentType("application/json");
  30. client.Timeout = TimeSpan.FromMilliseconds(2000);
  31. client.Post(data);
  32. var response = await client.RequestAsync(url, "POST", cancellationToken);
  33. body = response.Body();
  34. var root = body.Convert2JsonElement();
  35. int code = root.Read<int>("code");
  36. string qs = root.PathRead<string>("body.qs");
  37. if (code == 200)
  38. {
  39. return qs;
  40. }
  41. _ = new LoggerLibrary("JdUnion", "h5st").Info(body).SaveAsync();
  42. }
  43. catch (Exception ex)
  44. {
  45. _ = new LoggerLibrary("JdUnion", "h5st_error")
  46. .Info(body)
  47. .Info(ex.Message, ex.StackTrace)
  48. .SaveAsync();
  49. }
  50. return string.Empty;
  51. }
  52. }
  53. }