WEB开发者-分享WEB开发知识,让开发变得更简单!

解析高佣二合一链接的e参数

解析高佣二合一链接的e参数---获取商品信息

[参考链接](https://www.jianshu.com/p/a8b1122eff93)
根据解析淘口令获取返回的商品链接,解析e参数获取商品id信息

    $appkey = "12574478"; //固定值
    $url = "https://acs.m.taobao.com/h5/mtop.alimama.union.hsf.mama.coupon.get/1.0/?appKey={$appkey}&v=1";
    $cookie_all = get_headers($url, true)['Set-Cookie'];  //获取cookie值
    $setCookie = explode(";", $cookie_all[0])[0];   //_m_h5_tk
    $setCookie1 = explode(";", $cookie_all[1])[0]; //_m_h5_tk_enc
    $cookie = $setCookie . ";" . $setCookie1 . ';';  //拼接cookie值
    $_m_h5_tk = substr($setCookie, strripos($setCookie, "=") + 1);
    $_m_h5_tk_first = explode("_", $_m_h5_tk)[0];
    parse_str(parse_url($taobao_info['url'])['query'], $out);
    $e_data = json_encode(['e' => $out['e']]);
    $time = time() . '000';
    $sign = md5($_m_h5_tk_first . '&' . $time . '&' . $appkey . '&' . $e_data);
    $e_data = urlencode($e_data);
    $http_url = "https://acs.m.taobao.com/h5/mtop.alimama.union.hsf.coupon.get/1.0/?jsv=2.4.0&appKey={$appkey}&t={$time}&sign={$sign}&api=mtop.alimama.union.hsf.coupon.get&v=1.0&AntiCreep=true&AntiFlood=true&type=jsonp&dataType=jsonp&callback=mtopjsonp1&data={$e_data}";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $http_url);
    $header = array();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);    //请求时带cookie值
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); //设置等待时间
    $content = curl_exec($ch);
    curl_close($ch);
    $content_last = substr($content, 0, strlen($content) - 1);
    $content = str_replace('mtopjsonp1(', '', $content_last);
    $data = json_decode($content, true);
    var_dump($data);

本文链接:https://www.webkfz.com/WEBkF/PHP/74030.html

版权声明:站内所有文章皆来自网络转载,只供分享作用,不代表本站的观点!

发表评论 共有 0 条评论)

联系客服
网站客服 业务合作 QQ
1244305267
公众号
公众号
公众号
返回顶部