The main search engine Ping service PHP implementation method

Source: Internet
Author: User

Major search engine Ping service PHP implementation method to make the site quickly included
"1" Manual ping Service Address:
Baidu Address: http://ping.baidu.com/ping.html
Google (google) address: http://blogsearch.google.com/ping
Feedsky (Flying) Address: http://ping.feedsky.com/ping.html
Qihoo (Qihoo) Address: http://so.blog.qihoo.com/pingblog.html
Iask (love to ask) address: http://blog.iask.com/ping.php


"2" Auto Ping Service Application Programming Interface (API):  
Google: http://blogsearch.google.com/ping/RPC2 
feedburner:http://ping.feedburner.com 
Feedsky (flying): http://www.feedsky.com/api/RPC2 
feedster:http://api.feedster.com/ping.php 
Iask (Love Q): http://blog.iask.com/RPC2 
Qihoo (Qihoo): http ://ping.blog.qikoo.com/rpc2.php 
Fresh fruit: http://www.xianguo.com/xmlrpc/ping.php 
Catch 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 


Provided above, including the above-mentioned ping service, some I try to use some bad, to use those that look at the situation. This oneself according to the network environment and so on self-test, suitable is the best, no recommendation.
Well, say so much above, the following is the focus, that is, how to implement the ping service, WordPress can be implemented through the background, the other that? What about blogging that doesn't have a ping service feature? According to what is known, the blog system good use of the WordPress ping function, undoubtedly, the ASP class Z-blog seemingly can be implemented through plug-ins to achieve this function. Other blogging system? The other? No other, my choice is only WordPress, no other, as long as the only. Oh, no kidding. The following is the question of PHP to implement the ping service, this for other non-support ping function of the site or the system, we can develop a self-interface implementation. For example, Dedecms's two-time development is possible, and has recently been studying the project.
Need to say is Baidu's Ping and Google's submission format is different, the following simple to say, respectively to Baidu and Google to do an introduction, the first introduction is Google (why is not Baidu, OK?) Don't be so tangled, there will be ... ):
"* *" the implementation of Google's ping service php
A detailed introduction to RPC can be in the Wikipedia, Google Ping service standard:
RPC Endpoint: http://blogsearch.google.com/ping/RPC2
Call Method Name: weblogupdates.extendedping
Parameters: (should be delivered in the same order as listed below)
Station name
Site URL
Need to check for updated page URLs
The URL of the corresponding RSS, RDF, or Atom seed
Optional: the category name (or label) of the page content. You can specify multiple values, with ' | ' characters are delimited.
The first thing to do is write a curl function to post the Google RPC endpoint:

Copy CodeThe 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 standard, detailed request examples can refer to the official case, click here.
My code, for example, is written like this:

Copy CodeThe code is as follows:
$googleXML = <<<end
<?xml version= "1.0″?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param>
<value>ping Service PHP Implementation method, so that the site is quickly included </value>
</param>
<param>
<value>http://s.jb51.net</value>
</param>
<param>
<value>http://s.jb51.net/archives/47.html</value>
</param>
<param>
<value>http://s.jb51.net/feed</value>
</param>
</params>
</methodCall>
END;
$res = PostURL (' http://blogsearch.google.com/ping/rpc2′, $googleXML);
The following is the decision to return success (based on the interface description of Google ping)
if (Strpos ($res, "<boolean>0</boolean>"))
echo "Ping succeeded";
Else
echo "Ping failed";


OK, this can be a simple implementation of the Google Ping service. This function can be implemented according to the Code self-modification.
"* *" Baidu's Ping Service PHP implementation (this title true dt)
Baidu's Ping service XML code is different from Google, Baidu will always have its own characteristics:
Introduction under the Baidu Blog Ping Service, Baidu Blog Ping Service Detailed introduction, please visit: http://www.baidu.com/search/blogsearch_help.html#n7.
Baidu's Ping service is based on the XML-RPC standard protocol, but unlike the Google Ping service is the Baidu Ping sent the XML format is different, we need to use the string node package content.
For example:

Copy CodeThe code is as follows:
<?xml version= "1.0″encoding=" utf-8″?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param>
<value><string>ping Service PHP Implementation method, so that the site is quickly included </string></value>
</param>
<param>
<value><string>http://s.jb51.net/</string></value>
</param>
<param>
<value><string>http://s.jb51.net/archives/47.html</string></value>
</param>
<param>
<value><string>http://s.jb51.net/feed</string></value>
</param>
</params>
</methodCall>


According to the above mentioned Google interface, we just change the submitted XML content can, of course, Baidu Ping service return judgment is different from Google, can also make corresponding changes,
Here's the code for PHP:

Copy CodeThe code is as follows:
$baiduXML = <<<eot
<?xml version= "1.0″encoding=" utf-8″?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param><value><string>ping Service PHP Implementation method, so that the site is quickly included </string></value></param>
<param><value><string>http://s.jb51.net</string></value></param>
<param><value><string>http://s.jb51.net/archives/47.html</string></value></ Param>
<param><value><string>http://s.jb51.net/feed</string></value></param>
</params>
</methodCall>
EOT;
$res = PostURL (' http://ping.baidu.com/ping/rpc2′, $baiduXML);
The following is the decision to return success (according to the interface description of Baidu Ping)
if (Strpos ($res, "<int>0</int>"))
echo "Ping succeeded";
Else
echo "Ping failed";


The above code can implement the PHP ping service. Well, the following to provide you with a Baidu Ping service code, no way who let him so unique that?

Copy CodeThe code is as follows:
<?php
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 = "<?xml version=\" 1.0\ "encoding=\" gb2312\ "?>
<methodCall>
<methodName>weblogUpdates.extendedPing</methodName>
<params>
<param><value><string> Scripting House </string></value></param>
<param><value><string>http://www.jb51.net</string></value></param>
<param><value><string>http://www.jb51.net/a/15222.html</string></value></ Param>
<param><value><string>http://www.jb51.net</string></value></param>
</params>
</methodCall> ";
$res = PostURL (' http://ping.baidu.com/ping/rpc2′, $baiduXML);
if (Strpos ($res, "<int>0</int>"))
{
echo "Ping succeeded";
}
Else
{
echo "Ping failed";
}
?>

The main search engine Ping service PHP implementation method

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.