添加以下代码就可以实现发布信息的时候自动推送到百度
在userfun.php中添加
function postbaidu($url){ $urls=array(); array_push($urls,$url); $api = 'https://data.zz.baidu.com/urls?site=https://www.XXXXXXXXXXXXXXXXXX.cn&token=秘钥'; $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); $result = curl_exec($ch); file_put_contents("post2baidu.html", $url.":".$result."<br/>",FILE_APPEND); }
在hinfofun.php AddNews函数中添加蓝色高亮内容:
//信息地址 $updateinfourl=''; //添加 $posturl=''; if(!$add['isurl']) { $infourl=GotoGetTitleUrl($add['classid'],$id,$newspath,$filename,$add['groupid'],$add['isurl'],$add['titleurl']); $updateinfourl=",titleurl='$infourl'"; //添加 $posturl="https://www.XXXXXXXXXXXXXXX.cn".$infourl; } $usql=$empire->query("update ".$infotbr['tbname']." set filename='$filename'".$updateinfourl.$addtitlepic." where id='$id'"); //替换图片下一页 .... if($sql) { //返回地址 if($add['ecmsfrom']&&(stristr($add['ecmsfrom'],'ListNews.php')||stristr($add['ecmsfrom'],'ListAllInfo.php'))) { $ecmsfrom=$add['ecmsfrom']; } else { $ecmsfrom=$add['ecmsnfrom']==1?"ListNews.php?bclassid=$add[bclassid]&classid=$add[classid]":"ListAllInfo.php?tbname=".$class_r[$add[classid]][tbname]; $ecmsfrom.=hReturnEcmsHashStrHref2(0); } //添加 postbaidu($posturl); $GLOBALS['ecmsadderrorurl']=$ecmsfrom.$addecmscheck; insert_dolog("classid=$add[classid]<br>id=".$id."<br>title=".$add[title],$pubid);//操作日志 printerror("AddNewsSuccess","AddNews.php?enews=AddNews&ecmsnfrom=$add[ecmsnfrom]&bclassid=$add[bclassid]&classid=$add[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0)); }