The php implementation method of Ping service allows websites to be quickly indexed _ PHP Tutorial

Source: Internet
Author: User
The php implementation method of Ping service allows websites to be quickly indexed. This article continues to address the ping service problem. First, we will summarize the following information: [1] manual Ping service address: Baidu (Baidu) address: ping.baidu.comping.html Goog this article continues to talk about the ping service problem. first, summarize and summarize the following information:
[1] manually Ping the service address:
Baidu address: http://ping.baidu.com/ping.html
Google address: http://blogsearch.google.com/ping
Feedsky address: http://ping.feedsky.com/ping.html
Qihoo (Qihoo) Address: http://so.blog.qihoo.com/pingblog.html
IASK address: http://blog.iask.com/ping.php
[2] automatic Ping service application programming interface (API ):
Google: http://blogsearch.google.com/ping/RPC2
Feedburner: http://ping.feedburner.com
Feedsky: http://www.feedsky.com/api/RPC2
Feedster: http://api.feedster.com/ping.php
IASK: http://blog.iask.com/RPC2
Qihoo (Qihoo): http://ping.blog.qikoo.com/rpc2.php
Fruit: http://www.xianguo.com/xmlrpc/ping.php
Shrimp: http://www.zhuaxia.com/rpc/server.php
Blogdigger: http://www.blogdigger.com/RPC2
Blo. gs: http://ping.blo.gs/
ICEROCKEThttp: // rpc.icerocket.com: 10080/
Moreover: http://api.moreover.com/RPC2
Newsgator: http://rpc.newsgator.com/
Syndic8: http://www.syndic8.com/xmlrpc.php
Weblogs: http://rpc.weblogs.com/RPC2
Weblogalot: http://ping.weblogalot.com/rpc.php
The above provides, including the ping service mentioned above, some of which I tried to be useful, some of which are difficult to use, depending on the situation. This is suitable for self-testing based on the network environment, and is not recommended.
Well, after talking about so many of the above, the following is the focus, that is, how to implement the ping service, wordpress can be implemented through the background, and what else? For example, what do Blog programs without the ping service function do? According to different know, blog system in the use of WORDPRESS built-in PING function, without doubt, ASP class Z-BLOG seems to be able to achieve this function through the plug-in. Other blog systems? Others? There are no other options. my options are only wordpress, and there are no other options, as long as they are unique. Haha, no kidding. The following describes how to implement the ping service in php. for other websites or systems that do not support the ping function, you can develop an interface. For example, the secondary development of DEDECMS can be achieved.
It should be said that Baidu's ping and Google's submission formats are different. The following is a brief introduction to Baidu and Google respectively. The first introduction is Google (why not Baidu, OK? Don't be so entangled, there will be ......) :
[* 1] php implementation of Google's ping service
For details about RPC, refer to Wikipedia and Google's ping service standards:
RPC endpoint: http://blogsearch.google.com/ping/RPC2
Call method name: weblogUpdates. extendedPing
Parameters: (transmitted in the same order as listed below)
Site Name
Site URL
Page URL to be updated
URL of the corresponding RSS, RDF, or Atom seed
Optional. Category name (or tag) of the page content ). You can specify multiple values separated by the '|' character.
First, write a CURL function to POST Google's RPC endpoint:

The code is as follows:


Function postUrl ($ url, $ postvar ){
$ Ch = curl_init ();
$ Headers = array (
"POST". $ url. "HTTP/1.0 ″,
"Content-type: text/xml; charset = \" UTF-8 \"",
"Accept: text/xml ",
"Content-length:". strlen ($ postvar)
);
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headers );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postvar );
$ Res = curl_exec ($ ch );
Curl_close ($ ch );
Return $ res;
}


After the main curl is written, the rest is to assemble the data sent according to Google's XML-RPC standards, detailed request examples can refer to the official case, click here.
For example, my code is written as follows:

The code is as follows:


$ GoogleXML = <

WeblogUpdates. extendedPing


The php implementation method of Ping service allows websites to be quickly indexed


Http://s.jb51.net </value>


Http://s.jb51.net/archives/47.html </value>


Http://s.jb51.net/feed </value>



END;
$ Res = postUrl ('http: // blogsearch.google.com/ping/rpc2', $ googleXML );
// The following is the result of a successful response (according to the instructions on the Google ping interface)
If (strpos ($ res ," 0 "))
Echo "PING successful ";
Else
Echo "PING failed ";


OK, so that you can simply implement Google's PING service. You can modify the code to implement this function.
[* 2] php implementation of Baidu's ping service (this title is DT)
Baidu's ping service xml code is different from Google's. Baidu always has its own characteristics:
For more information about the Baidu blog ping service and Baidu blog Ping service, see http://www.baidu.com/search/blogsearch_help.html#n7.
Baidu's ping service is also based on the XML-RPC standard protocol, but unlike Google's ping service, Baidu's ping sent xml format is different, we need to use string node package content.
For example:

The code is as follows:




WeblogUpdates. extendedPing


The php implementation method of Ping service allows websites to be quickly indexed


Http://s.jb51.net/</string>


Http://s.jb51.net/archives/47.html </string>


Http://s.jb51.net/feed </string>




According to the Google interface mentioned above, we only need to change the submitted xml content. of course, the Baidu ping service returns a different judgment from Google's and can also make corresponding modifications,
The following is the php code:

The code is as follows:


$ BaiduXML = <

WeblogUpdates. extendedPing

The php implementation method of Ping service allows websites to be quickly indexed
Http://s.jb51.net </string>
Http://s.jb51.net/archives/47.html </string>
Http://s.jb51.net/feed </string>


EOT;
$ Res = postUrl ('http: // ping.baidu.com/ping/rpc2', $ baiduXML );
// The following is the result of success or failure (based on Baidu ping's interface description)
If (strpos ($ res ," 0 "))
Echo "PING successful ";
Else
Echo "PING failed ";


The above code can implement the php ping service. Well, I will provide you with a Baidu ping Service Code. no one can make him so unique?

The code is as follows:


Function postUrl ($ url, $ postvar)
{
$ Ch = curl_init ();
$ Headers = array (
"POST". $ url. "HTTP/1.0 ″,
"Content-type: text/xml; charset = \" gb2312 \"",
"Accept: text/xml ",
"Content-length:". strlen ($ postvar)
);
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headers );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postvar );
$ Res = curl_exec ($ ch );
Curl_close ($ ch );
Return $ res;
}
$ BaiduXML ="

WeblogUpdates. extendedPing

Foot home
Http://www.jb51.net </string>
Http://www.jb51.net/a/15222.html </string>
Http://www.jb51.net </string>

";
$ Res = postUrl ('http: // ping.baidu.com/ping/rpc2', $ baiduXML );
If (strpos ($ res ," 0 "))
{
Echo "PING successful ";
}
Else
{
Echo "PING failed ";
}
?>


In this article, I wasted N drafts on DT before writing them. then I found that I needed a CODE plug-in for WP equipment. The code issue is really tangled, and the WP topic of Chinese people does not support paging. This makes me very DT. after talking about it for a long time, what is DT? I don't know ......

Manual Ping service address: Baidu (Baidu) Address: http://ping.baidu.com/ping.html Goog...

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.