PHP 版访客访问文章自动推送百度资源平台,增加收录
資深大佬 : xiamuguizhi 3
前言
有人要,我就单独从主题提取出来了! 原来有百度自动图推送有 js 版本,现在好像不能用了。我就随便整了个 PHP 版本的效果还是一样的!
效果图

自动推送代码
这个是判断文章是否已经收录。未收录推送以收录不推送以免造成重复推送!!
<?php $cxurl='https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; function okBaidu($url){ $url='http://www.baidu.com/s?wd='.$url; $curl=curl_init(); curl_setopt($curl,CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); $rs=curl_exec($curl); curl_close($curl); if(!strpos($rs,'提交网址')){ echo "文章状态:已收录~"; }else{ $pageURL = (@$_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; $pageURL .= $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; $urls = array( $pageURL ); $api = 'http://data.zz.baidu.com/urls?site=https://jiba.icu&token=OWYiTZcIYZ1dwEcD'; //自行修改 百度 接口调用地址 $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode("n", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); //第二种 的返 bai 结果是以 json 形式。 $res=json_decode(curl_exec($ch),true); $ed = ($res['remain']);//起作用 $cg = ($res['success']);//起作用 echo "文章状态:未收录,以推送~ [今日剩余额度:$ed 条] "; } } echo okBaidu($cxurl); ?>
不判断是否收录
这种是无脑死推版本,管你收录没收录就死推送 哈哈!
$pageURL = (@$_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; $pageURL .= $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; $urls = array( $pageURL ); $api = 'http://data.zz.baidu.com/urls?site=https://jiba.icu&token=OWYiTZcIYZ1dwEcD'; //自行修改 百度 接口调用地址 $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode("n", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); //第二种 的返 bai 结果是以 json 形式。 $res=json_decode(curl_exec($ch),true); $ed = ($res['remain']);//起作用 $cg = ($res['success']);//起作用 echo "文章状态:未收录,以推送~ [今日剩余额度:$ed 条] ";
一些参数
调用方法: $ed = ($res['remain']);
success 是 int 成功推送的 url 条数 remain 是 int 当天剩余的可推送 url 条数 not_same_site 否 array 由于不是本站 url 而未处理的 url 列表 not_valid 否 array 不合法的 url 列表
大佬有話說 (3)