Baidu Sitemap Real-time push code

Source: Internet
Author: User
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
  1. function Tobaidu ($url) {
  2. $ntime =time ();
  3. $now = Date (' y-m-d ', $ntime);
  4. $data = " ;
  5. $data. = ' ;
  6. $data. = ' ;
  7. $data. = ' '.$url.' ;
  8. $data. = ' . $now. ' ';
  9. $data. = ' daily ';
  10. $data. = ' 0.8 ';
  11. $data. = ';
  12. $data. = ';
  13. $pingurl = "Http://ping.baidu.com/sitemap?site=www.xxx.com&resource_name=sitemap&access_token=XXXXXXX"; /Your interface address
  14. $curl = Curl_init (); Start a Curl session
  15. curl_setopt ($curl, Curlopt_url, $pingurl); The address to be accessed
  16. curl_setopt ($curl, Curlopt_ssl_verifypeer, 0); Examination of the source of the certification certificate
  17. curl_setopt ($curl, Curlopt_ssl_verifyhost, 1); Check that the SSL encryption algorithm exists from the certificate
  18. curl_setopt ($curl, Curlopt_useragent, "curl/7.12.1"); Simulating the browser used by the user
  19. curl_setopt ($curl, Curlopt_cookie, $cookie);
  20. curl_setopt ($curl, Curlopt_referer, "");
  21. curl_setopt ($curl, Curlopt_post, 1); Send a regular POST request
  22. curl_setopt ($curl, Curlopt_postfields, $data); Post-Submitted packets
  23. curl_setopt ($curl, Curlopt_timeout, 30); Setting a timeout limit to prevent a dead loop
  24. curl_setopt ($curl, Curlopt_header, 0); Displays the contents of the header area returned
  25. curl_setopt ($curl, Curlopt_returntransfer, 1); Gets the information returned as a file stream
  26. $tmpInfo = curl_exec ($curl); Perform actions
  27. if (Curl_errno ($curl)) {
  28. Echo ' Errno '. Curl_error ($curl);//Catch exception
  29. }
  30. Curl_close ($curl); Turn off the Curl session
  31. return $tmpInfo; Return data
  32. }
  33. $tt = Tobaidu ("http://www.appleshu.com/");
Copy Code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.