Before, Dreamweaver had a set of plug-ins for actively pinging Baidu, but later it became unusable. In the end Baidu has launched a real-time push link address to Baidu. This is much more convenient and easier to use than sitemap, and it can also ensure the originality of the article. Below, I read the relevant information and wrote an article based on Baidu's interface to push the sitemap map to Baidu in real time. Share the solution with everyone.
I have written two methods about Baidu real-time push of Dreamweaver, you can choose by yourself:
1. Manually create a file and access this file every day to push all the articles of the day to the Baidu search engine. Create a tuisong.php under the root directory and after accessing it, the Baidu interface results will be returned
<?php require_once ("include/common.inc.php"); require_once "include/arc.partview.class.php"; require_once('include/charset.func.php'); $year = date("Y"); $month = date("m"); $day = date("d"); $dayBegin = mktime(0,0,0,$month,$day,$year);//当天开始时间戳 $dayEnd = mktime(23,59,59,$month,$day,$year);//当天结束时间戳 $query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin.""; //这里dede换成你们自己的表前缀 $urls=""; $dsql->Execute('arch.id,types.typedir',$query); while($row = $dsql->GetArray('arch.id,types.typedir')) { $urls.="http://www.baidu.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; //将上边的http://baidub.com换成你的网址 } $urls=substr($urls,0,-1); $urls = explode(",",$urls); $api = 'http://data.zz.baidu.com/urls?site=www.baidu.com&token=hereistoken'; // 前边的site换成自己的site xxx换成自己的密钥 $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); echo $result.count($urls); ?>
View push feedback
Push successful
The status code is 200 and the following fields may be returned:
Field Is it required? Parameter type Description
success is int the number of urls successfully pushed
remain is int the remaining number of pushable URLs on the day
not_same_site No array List of URLs that have not been processed because they are not the URLs of this site
not_valid No array Illegal url list
Successful return example:
Copy code The code is as follows:
{
"remain":4999998,
"success":2,
"not_same_site":[],
"not_valid":[]
}
Push failed
The status code is 4xx, and the return fields are:
Field Type Description
error is an int error code, the same as the status code
message is string error description
Failure return example:
Copy code The code is as follows:
{
"error":401,
"message":"token is not valid"
}
2. The second way is to publish an article, just like Baidu pushes it once. This is more convenient, and this is what I use
Open the article_add.php file in Dreamweaver Backend. Find almost 262 lines
Note:
If your system settings-》Core Options
If it is direct. Add the following code, otherwise pay attention to the following tips
//百度推送 $urls="http://www.baidu.com".$artUrl;//前面域名换成你自己的 如果上面图片选择的是是 就把"http://baidu.com". 去掉 $urls = explode(",",$urls); $api = 'http://data.zz.baidu.com/urls?site=www.0cx.cc&token=hereistoken'; // 前边site换成自己的site xxx换成自己的密钥 $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);
It’s OK. If you want to see whether the addition is successful, you can modify the following one or two lines of code
Copy code The code is as follows:
Please select your subsequent operation ".$result.$urls[0].":
result refers to the results returned by Baidu, and urls refers to the URLs you push.
It’s basically OK. If you want the article to be pushed when you modify it, just modify article_edit.php like I did above.
The above is the entire content of this article, I hope you all like it.