Sin descripción

SmsNewHelper.cs 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace CallCenter.Utility
  8. {
  9. public static class SmsNewHelper
  10. {
  11. public static string Send(string mobile,string content)
  12. {
  13. string result = string.Empty;
  14. var param = new
  15. {
  16. ecName = "安阳市行政便民服务中心",
  17. apId = "ayrx",
  18. mobiles = mobile,
  19. content = content,
  20. sign = "q4dGVsCk2",
  21. addSerial = "",
  22. mac = MD5("安阳市行政便民服务中心" + "ayrx" + "Ay+12345-Rx" + mobile + content + "q4dGVsCk2").ToLower(),
  23. };
  24. string sendresult = HttpMethods.HttpPost("http://112.35.1.155:1992/sms/norsubmit", Convert.ToBase64String(Encoding.UTF8.GetBytes(param.ToJson())), "application/json");
  25. var rt = sendresult.ToJObject();
  26. //success
  27. if (rt["success"].ToString() == "false")
  28. {
  29. result = rt["rspcod"].ToString();
  30. }
  31. return result;
  32. }
  33. /// <summary>
  34. /// MD5函数
  35. /// </summary>
  36. /// <param name="str">原始字符串</param>
  37. /// <returns>MD5结果</returns>
  38. public static string MD5(string str)
  39. {
  40. byte[] b = Encoding.UTF8.GetBytes(str);
  41. b = new MD5CryptoServiceProvider().ComputeHash(b);
  42. string ret = "";
  43. for (int i = 0; i < b.Length; i++)
  44. ret += b[i].ToString("x").PadLeft(2, '0');
  45. return ret;
  46. }
  47. }
  48. }