zoukankan      html  css  js  c++  java
  • 淘宝客根据优惠券url更新优惠券信息

                string m_h5_tk = "6ad772f2d0833a8e302c5ae68d65eaa0";
                string time = ToUnixTimestampBySeconds().ToString();
                string appKey = "12574478";
                string data = JsonConvert.SerializeObject(new { e = "w4TDo/jOMecNfLV8niU3RxrSI/Oabn6qNg4Gqf8CT4AKuDLwELihnRbQhr+5FtsAh9KaCsCm+R32yVMpbbWtUWwCdh1fz0zYK5wEWaT+OkzWZTH/haUuJ+3FJUPORYvyhPbd0JgRLDq3GXpSbfs48lGikzdUqsEO7RwD1Eg9p5/o27RMW2YwFNweCPWKo1fUyUxONJCwrinluAYBRglsbQ==" });
                string sign = GetSign(string.Join('&', new string[] { m_h5_tk, time, appKey, data }));
                data = HttpUtility.UrlEncode(data);
                string apiUrl = $"https://acs.m.taobao.com/h5/mtop.alimama.union.hsf.coupon.get/1.0/?jsv=2.4.0&appKey=12574478&t={time}&sign={sign}&api=mtop.alimama.union.hsf.coupon.get&v=1.0&AntiCreep=true&AntiFlood=true&data={data}";
    

     m_h5_tk为访问mtop.alimama.union.hsf.coupon.get接口链接时,返回的cookies数据,注,返回cookies数据格式为:_m_h5_tk= 1c08cb77a7795d64c543cd1728e0135c_1529065507043,这里只使用前半部分,在这里是1c08cb77a7795d64c543cd1728e0135c;

       time为毫秒级时间戳;

       appKey为固定的值12574478;

       data为json字符串,e为优惠券url中的参数e的值;

     sign签名

       

            /// <summary>
            ///  时间转时间戳Unix-时间戳精确到秒
            /// </summary> 
            private static long ToUnixTimestampBySeconds()
            {
                DateTimeOffset dto = new DateTimeOffset(DateTime.Now);
                return dto.ToUnixTimeMilliseconds();
            }
            private static string GetSign(string strParameter)
            {
                using (var md5 = MD5.Create())
                {
    
                    var result = md5.ComputeHash(Encoding.UTF8.GetBytes(strParameter));
                    var strResult = BitConverter.ToString(result);
                    var sign = strResult.Replace("-", "").ToLower();
                    return sign;
                }
            }
    

      

  • 相关阅读:
    垃圾回收算法(1)标记-清除
    golang的interface剖析
    库文件的使用
    linux loadavg详解(top cpu load)
    撰写的《大数据处理框架Apache Spark设计与实现》出版了
    VUE文件上传删除、图片上传删除、视频上传删除
    三元运算符
    VScode格式化后单引号变双引号解决办法
    VUE实现分页
    绝望!新手小白在VUE组件之间进行传值上浪费了很多时间~
  • 原文地址:https://www.cnblogs.com/lkd3063601/p/13501959.html
Copyright © 2011-2022 走看看