下面是一键采集微信文章留言、阅读量、点赞量、转发分享数、在看数、正文内容、biz值、正文内容、封面图等的SDK实例代码,大家可以把下面的代码保存为*.php,运行一下即可查看到效果!!
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0,viewport-fit=cover">
</head>
<body>
<?php
if(empty($_GET['send']))
{
echo '<form action="?send=yes" method="post">';
echo '<input type="text" name="link_href" style="width:600px;padding:12px;" placeholder="请输入微信文章地址">';
echo '<br>';
echo '<br>';
echo '<input type="submit" value="确定采集" style="font-size:18px;">';
echo '</form>';
} elseif($_GET['send']=='yes' && stripos($_POST['link_href'],'mp.weixin.qq.com')!=false) {
echo '采集中……,稍等一下……';
$ApiCollect_appid='hzwwwwzhiwu55comwwwzhiwu55comhzw';
$ApiCollect_appid_key='155120699Atqqcom155120699Atqqcom';
$t=time();
$dataArr=array();
$dataArr['appid']=$ApiCollect_appid;
$dataArr['link_href']=$_POST['link_href'];
$dataArr['callback_post_link']=''; // 这儿填写接收采集结果数据的地址,采集完成之后,会第一时间把结果推送到这个地址,参考实例代码:http://discuz.zhiwu55.vip/admin.php?action=plugins&operation=config&do=10&identifier=zhiwu55_wxcollect&pmod=hzw_run
$dataArr['t']=$t;
$sign=md5($ApiCollect_appid.$ApiCollect_appid_key.$dataArr['link_href'].$dataArr['callback_post_link'].$t);
$dataArr['sign']=$sign;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ai.zhiwu55.com/ApiCollectPostData');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if(curl_errno($ch)){
echo 'cURL 错误: ' . curl_error($ch);
exit;
}
curl_close($ch);
if(stripos($response,'hzw_success')===0)
{
echo '<script>setTimeout(function(){window.location.href="?send=yes&appid=hzwwwwzhiwu55comwwwzhiwu55comhzw&sign='.$sign.'";},10000);</script>';
}
} elseif(strlen($_GET['appid'])==32 && strlen($_GET['sign'])==32) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ai.zhiwu55.com/ApiCollectHandUpdateData');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('appid'=>$_GET['appid'],'sign'=>$_GET['sign']));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if(curl_errno($ch)){
echo 'cURL 错误: ' . curl_error($ch);
exit;
}
curl_close($ch);
if(strlen($response)<200)
{
echo '采集中……,稍等一下……';
echo '<script>setTimeout(function(){window.location.reload();},5000);</script>';
} else {
$responseArr=unserialize(base64_decode($response));
echo '<pre>';
print_r($responseArr);
echo '</pre>';
}
}
?>
</body>
</html>