Zhimeng sitemap real-time push to Baidu tutorial

Source: Internet
Author: User
This article describes how to push the map to Baidu in real time by zhimeng sitemap. For more information, see

This article describes how to push the map to Baidu in real time by zhimeng sitemap. For more information, see

Previously, Weaver dream had a set of plug-ins to actively ping Baidu, but it could not be used later. Finally, Baidu launched a real-time push link address to Baidu, which is much easier to use than sitemap, in addition, I can ensure the originality of the Article. Next I will share with you how to push the sitemap to Baidu in real time based on Baidu's interface.

I have written two methods for zhimeng's Baidu real-time push:

1. manually create a file. When you access this file every day, you can push all the articles of the day to Baidu search engine. After you create a tuisong. php file under the root directory, Baidu interface results will be returned.

<? Phprequire_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, $ month, $ day, $ year); // The start timestamp of the day $ dayEnd = mktime (, 59, $ month, $ day, $ year); // The end timestamp of the day $ 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. ""; // here, dede is replaced with your own table prefix $ 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'])." http://www.jb51.net/ ". $ Row [id]. ". html ". ","; // Replace the preceding URL with your url} $ urls = substr ($ urls, 0,-1); $ urls = explode (",", $ urls); $ api =' http://data.zz.baidu.com/urls?site=www.baidu.com&token=hereistoken '; // Replace the front site with your own site xxx with your own key $ 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

If the status code is 200, the following fields may be returned:
Description of required parameter types
Success is the number of successfully pushed URLs by int.
Remain is the number of remaining push URLs on the day of int.
Not_same_site no array list of URLs not processed because it is not the site url
Not_valid no array illegal url list
Success response example:

The Code is as follows:


{
"Remain": 4999998,
"Success": 2,
"Not_same_site": [],
"Not_valid": []
}

Push failed

The status code is 4xx, and the returned fields include:
Required field type description
Error is an int error code, which is the same as the status code.
Message is a string error description.
Example of failure response:

The Code is as follows:


{
"Error": 401,
"Message": "token is not valid"
}

2. The second is to publish an article, just like Baidu push once. This is more convenient and I use this

Open the article_add.php file in the background of zhimeng. Find the 262 rows.

Note:
If you set the-core options

If you want to directly Add the following code, otherwise note the following prompt:

// Baidu push $ urls = "http://www.baidu.com ". $ artUrl; // replace the previous domain name with your own ". remove $ urls = explode (",", $ urls); $ api = 'HTTP: // data.zz.baidu.com/urls? Site = www.0cx. cc & token = hereistoken '; // Replace the front site with your own site xxx with your own key $ 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 );

OK. If you want to see if the code is successfully added, you can modify the following one or two lines of code.

The Code is as follows:


Please select your subsequent operations ". $ result. $ urls [0].":


The result is the result returned by Baidu, And the urls is the url you pushed.

Basically, it's okay. If you want to push the fact when you modify the article, you just need to modify article_edit.php like above.

The above is all the content of this article. I hope you will like it.

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.