PHP + fiddler capture micro-channel number read several articles thumbs up collection

Summary:

Analysis interface to get to know the number of articles read and praise must have a number of key points and uin two key parameters, different public key numbers are not the same (said to have universal micro letter key, do not know how to get), with a number of key public about half hours expire

Submit link for articles of read api

Ideas:

1. The client requested amount interface to intercept read requests are forwarded to your own server, so that you can get to the key, the cache associated with __biz half an hour

2. When submitting articles link to query the server to obtain links from articles in __biz, check whether the current buffer number corresponding to the public key, any, proceed to step 3, do not go to step 4.

3.curl request https://mp.weixin.qq.com/mp/getappmsgext? Interface to obtain data

When there is no 4.key after informing the client is redirected to the url (websocket notice or notification client ajax poll, need to modify the code in the article details page packet capture tool allowed to jump to the middle of the page on standby, open the article page every few seconds jump back to the middle of page) to suspend the program for a few seconds and wait for the client to update key, then the client submitted a new key, with its inquiries

 

achieve

1. Ethereal

This interface is the interface to obtain the amount of reading, the following parameters FIG.

2. This interface to intercept forwarded to your server, click (function performed prior to the formal request) rules- customize rules in OnBeforeRequest plus

if (oSession.fullUrl.Contains("mp.weixin.qq.com/mp/getappmsgext"))
		{
			oSession.oRequest["Host"]= 'ccc.aaa.com' ;
		}

Effect, you can see this interface has been forwarded

3. The server cache key, for example PHP code

 

    public function saveKey(Request $request)
    {
        $__biz = $request->param('__biz',0);
        $data['uin'] = $request->param('uin',0);
        $data['key'] = $request->param('key',0);
        Cache::set($__biz,$data,30 * 60);
        return 'ok';
    }

4. Submit Query API code article link

 public function getReadNum(Request $request)
    {
        $url = $request->param('url');

        parse_str(parse_url($url)['query'], $param);
        $__biz = $param['__biz'];
        $key_data = Cache::get($__biz);
        if (empty($key_data))
            return 'no key';
        $uin = $key_data['uin'];
        $key = $key_data['key'];
        $param['uin'] = $uin;
        $param['key'] = $key;
        $param['wxtoken'] = "777";
        $wechat_url = "https://mp.weixin.qq.com/mp/getappmsgext?" . http_build_query($param);
        //dump($wechat_url);

        $data = array(
            'is_only_read' => 1,
            'is_temp_url' => 0,
            'appmsg_type' => 9,
        );

        $res = $this->get_url($wechat_url,$data);

        return $res;

    }


function get_url($url,$data)
    {
        $ifpost = 1;//是否post请求
        $datafields = $data;//post数据
        $cookiefile = '';//cookie文件
        $cookie = '';//cookie变量
        $v = false;

        //模拟http请求header头
        $header = array("Connection: Keep-Alive","Accept: text/html, application/xhtml+xml, */*", "Pragma: no-cache", "Accept-Language: zh-Hans-CN,zh-Hans;q=0.8,en-US;q=0.5,en;q=0.3","User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 QBCore/4.0.1278.400 QQBrowser/9.0.2524.400 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2875.116 Safari/537.36 NetType/WIFI MicroMessenger/7.0.5 WindowsWechat");
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, $v);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        $ifpost && curl_setopt($ch, CURLOPT_POST, $ifpost);
        $ifpost && curl_setopt($ch, CURLOPT_POSTFIELDS, $datafields);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        $cookie && curl_setopt($ch, CURLOPT_COOKIE, $cookie);//发送cookie变量
        $cookiefile && curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);//发送cookie文件
        $cookiefile && curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);//写入cookie到文件
        curl_setopt($ch,CURLOPT_TIMEOUT,60); //允许执行的最长秒数
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        $ok = curl_exec($ch);
        curl_close($ch);
        unset($ch);
        return $ok;
    }

 

5. inform the client-side redirect page (I did not write this part, see my other reference texts socket on the article)

6. Use fiddler modified micro-channel article also jsj script,

In OnBeforeResponse (method performed prior to return to the client), add the code to jump to the middle of the page

 

effect

Published 85 original articles · won praise 45 · views 950 000 +

Guess you like

Origin blog.csdn.net/flysnownet/article/details/102793318