A ping, more formally known as an XML-RPC ping, is a method of allowing two websites to communicate with each other (via the XML-RPC specification). The most common use these days is for blog software to tell RSS feed directories and aggregators that a new feed has been published. If you aren’t using blog software for your site but would still like the ability to ping, you can use the code below. Note that it requires the inclusion of an open source class script, the Incutio XML-RPC Library (class-IXR.php).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php function weblog_ping($server = '', $path = '') { $blogname = "My Blog Name"; $blogurl = "http://www.blogdomain.com"; include_once ('class-IXR.php'); // using a timeout of 3 seconds should be enough to cover slow servers $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); $client->timeout = 3; $client->useragent .= ' -- phpAddEdit/0.9b'; // change to whatever you desire... // when set to true, this outputs debug messages by itself $client->debug = false; $client->query('weblogUpdates.ping', $blogname, $blogurl); } weblog_ping("rpc.pingomatic.com","/rpc"); weblog_ping("rpc.technorati.com","/rpc/ping"); weblog_ping("api.my.yahoo.com","/rss/ping"); ?> |
Note that I have included, but commented out, many of the ping targets because pingomatic will take care of most of them. Taylan Pince has published an article, Technorati and XML-RPC Pinging, which lays out an alternative to the code above and which uses the actual XML-RPC for PHP package.
Also, for some generally good information about this issue, check out the useful article, Increase Visibility in Blog and RSS Directories: XML-RPC Pings, which covers:
- technical background details of XML-RPC pings
- importance of XML-RPC pings
- requirements for using XML-RPC pings
- media types covered by XML-RPC
- Ping-o-Matic and other multi-pinging resources
- directories accepting XML-RPC pings
- live comments jotted down while performing pings
- resources related to XML-RPC
Download the code as a .zip file
Click to Add the First »