Interface Call Address: Http://ping.baidu.com/sitemap?site=www.xxx.com&resource_name=sitemap&access_token=XXXXXXX Parameters Site is a string on the Webmaster platform verified sites, such as www.example.com Resource_name data names you are allowed to push, such as Rdf_bbs_thread or Sitemap Access_token is the push access key for string on the webmaster platform.
This method is only applicable to Baidu Sitemap permission has been opened the Site page updates can be directly ping to Baidu. Can be viewed in the background of Baidu
Feedback Code
200 no use error, need to further observe whether the returned content is correct 400 required parameter not provided 405 Unsupported Request Mode, we only support post method to submit data 411 missing content-length field in HTTP header 413 push data is too large to exceed the limit of 10MB 422 the length of the Content-length declaration in the HTTP header is inconsistent with the actual transmitted data length 500 Webmaster Platform Server Internal Error
Www.appleshu.com the code provided by the Apple fiction web
- function Tobaidu ($url) {
- $ntime =time ();
- $now = Date (' y-m-d ', $ntime);
- $data = " ;
- $data. = ' ;
- $data. = ' ;
- $data. = ' '.$url.' ;
- $data. = ' . $now. ' ';
- $data. = ' daily ';
- $data. = ' 0.8 ';
- $data. = ';
- $data. = ';
- $pingurl = "Http://ping.baidu.com/sitemap?site=www.xxx.com&resource_name=sitemap&access_token=XXXXXXX"; /Your interface address
- $curl = Curl_init (); Start a Curl session
- curl_setopt ($curl, Curlopt_url, $pingurl); The address to be accessed
- curl_setopt ($curl, Curlopt_ssl_verifypeer, 0); Examination of the source of the certification certificate
- curl_setopt ($curl, Curlopt_ssl_verifyhost, 1); Check that the SSL encryption algorithm exists from the certificate
- curl_setopt ($curl, Curlopt_useragent, "curl/7.12.1"); Simulating the browser used by the user
- curl_setopt ($curl, Curlopt_cookie, $cookie);
- curl_setopt ($curl, Curlopt_referer, "");
- curl_setopt ($curl, Curlopt_post, 1); Send a regular POST request
- curl_setopt ($curl, Curlopt_postfields, $data); Post-Submitted packets
- curl_setopt ($curl, Curlopt_timeout, 30); Setting a timeout limit to prevent a dead loop
- curl_setopt ($curl, Curlopt_header, 0); Displays the contents of the header area returned
- curl_setopt ($curl, Curlopt_returntransfer, 1); Gets the information returned as a file stream
- $tmpInfo = curl_exec ($curl); Perform actions
- if (Curl_errno ($curl)) {
- Echo ' Errno '. Curl_error ($curl);//Catch exception
- }
- Curl_close ($curl); Turn off the Curl session
- return $tmpInfo; Return data
- }
- $tt = Tobaidu ("http://www.appleshu.com/");
Copy Code |