基于 PHP 的微信文章全数据(留言/点赞/阅读量等)一键采集 SDK 示例

下面是一键采集微信文章留言、阅读量、点赞量、转发分享数、在看数、正文内容、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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值