Ping service PHP Implementation method, so that the site is included in the rapid _php tutorial

Source: Internet
Author: User
This article goes on to talk about this ping service problem, first of all to sum up and summarize the following information:
"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 (google): http://blogsearch.google.com/ping/RPC2
Feedburner:http://ping.feedburner.com
Feedsky (Flying hand): 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 = <<

Weblogupdates.extendedping


Ping service PHP Implementation method, so that the site is quickly included


Http://s.jb51.net


Http://s.jb51.net/archives/47.html


Http://s.jb51.net/feed



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, " 0 "))
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:


Weblogupdates.extendedping


Ping service PHP Implementation method, so that the site is quickly included


http://s.jb51.net/


Http://s.jb51.net/archives/47.html


Http://s.jb51.net/feed




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 = <<

Weblogupdates.extendedping

Ping service PHP Implementation method, so that the site is quickly included
Http://s.jb51.net
Http://s.jb51.net/archives/47.html
Http://s.jb51.net/feed


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, " 0 "))
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:
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

Home of the script
Http://www.jb51.net
Http://www.jb51.net/a/15222.html
Http://www.jb51.net

";
$res = PostURL (' http://ping.baidu.com/ping/rpc2′, $baiduXML);
if (Strpos ($res, " 0 ") )
{
echo "Ping succeeded";
}
Else
{
echo "Ping failed";
}
?>

This article is very dt let me waste n a draft to write, and then found that need to get a code plug-in to WP equipment. Code problems really tangled, there is the Chinese WP theme does not support paging, this let me very dt, said a half-day, DT is what? I don't know......

http://www.bkjia.com/PHPjc/324871.html www.bkjia.com true http://www.bkjia.com/PHPjc/324871.html techarticle This article continues to talk about this ping service problem, first summarize and summarize the following information: "1" 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.