“微信运动”能够向朋友分享一个包含有运动数据的网页,网页中就有我们需要的数据。url类似于:http://hw.weixin.qq.com/steprank/step/personal?openid=用户的openid,其中有用于对于微信运动的唯一openid,打开fiddler进行抓包,首先打开fiddler,然后打开微信运动点击我的主页,如下:
此时如果顺利的话,fiddler会有微信浏览器请求这个url时,请求头的各个信息。
下面是代码部分:
$getOpenid = '这里填写openid';
$getHeader = array(
"Connection: keep-alive",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.691.400 QQBrowser/9.0.2524.400",
"Accept-Encoding: gzip, deflate",
"Accept-Language: zh-CN,zh;q=0.8,en-us;q=0.6,en;q=0.5;q=0.4",
);
$url = 'https://hw.weixin.qq.com/steprank/step/personal?opendi=' . $getOpenid;
//初始化
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//显示请求头
curl_setopt($ch, CURLOPT_HEADER, 1);
//头信息
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//设置User-Agent
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.691.400 QQBrowser/9.0.2524.400');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//发送cookie
curl_setopt($ch, CURLOPT_COOKIE, '这里填写cookie');
$response = curl_exec($ch);
echo $response;