Site Quality good site can be in the Baidu Webmaster Platform/Data submitted/sitemap column to see the real-time push function, the current tool is invited to open, Baidu Real-time push API interface can be real-time push our new release of the article, to ensure that Baidu in the first time included.
Baidu Webmaster Platform http://zhanzhang.baidu.com/
Open the Baidu Webmaster platform, click to open the real-time push to add new data interface to get token API push address:
http://Ping.baidu.com/sitemap?site=www.yourdomain.com&resource_name=sitemap&access_ Token=xxxxxxx
Share a user's written PHP real-time push code: PHP Real-time push new published articles
Fsocketopen Mode Push Sitemap
1 functionSitemap_ping_baidu ($urls){2 $baidu _ping_url= ' ping.baidu.com ';3 $get= '/sitemap?site=www.yourdomain.com&resource_name=sitemap&access_token=xxxxxxx ';4 $port=80;5 if( ($io=Fsockopen($baidu _ping_url,$port,$errno,$errstr, 50))!==false ) {6 $send= "POST$gethttp/1.1 "." Rn;7 $send. = ' Accept: */* '. " Rn;8 $send. = ' Cache-control:no-cache '. " Rn;9 Ten $send. = ' Host: '.$baidu _ping_url." Rn; One $send. = ' Pragma:no-cache '. " Rn; A //$send. = "referer:http://". $url. $get. " RN "; - //$send. = ' user-agent:mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; trident/4.0) '. ' RN "; - the $xml= ' <?xml version= ' 1.0 ' encoding= ' UTF-8 '?><urlset> '; - foreach($urls as $url){ - $xml. = ' <url> '; - $xml. = ' <loc><! [cdata['.$url.‘]] ></loc> '; + $xml. = ' <lastmod> '.Date(' y-m-d '). ' </lastmod> '; - $xml. = ' <changefreq>monthly</changefreq> '; + $xml. = ' <priority>0.8</priority> '; A $xml. = ' </url> '; at } - $xml. = ' </urlset> '; - - $send. = ' Content-length: '.strlen($xml)." Rn; - $send. = "Connection:closernrn"; - in $send.=$xml." Rn; - to fputs($io,$send ); + - $return= ' '; the while( !feof($io ) ) * { $ $return.=fread($io, 4096 );Panax Notoginseng } - return $return; the}Else{ + return false; A } the } + $return= Sitemap_ping_baidu (Array(' http://www.yourdomain.com/a.php?id=1 '));
After push Baidu will return the XML document
1 <?xml version= "1.0" encoding= "UTF-8"?> 2 <methodResponse> 3 < Params> 4 <param> 5 <value> 6 <int>200</int> 7 </value> 8 <param> 9 </params> </ Methodresponse>
The status code has the following meanings
Feedback Code Description
+ |
No usage error, need to see if the returned content is correct |
+ |
Required Parameters not available |
405 |
Unsupported Request method, we only support post method to submit data |
411 |
HTTP header missing Co Ntent-length field |
413 |
push data is too large to exceed the limit of 10MB |
422 |
HT The length of the Content-length declaration in the TP header is inconsistent with the actual length of data sent |
+ |
Webmaster Platform Server Internal Error |