
Drupal's ping module is less than desired. It relies upon the ability to ping pingomatic.com and have that site take care of notifying every site it knows about. But what if it fails to work?
Lets make sure we get those sites we want informed. In this little code snippet we will modify the ping_ping() function in ping.module to talk to pingomatic.com, technorati.com, and feedburner.com:
function ping_ping($name = '', $url = '') {
// pingomatic.com
// ----------------------
$result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
if ($result === FALSE) {
watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), array(), WATCHDOG_WARNING);
} else {
watchdog('directory ping', t('Successfully notified pingomatic.com (site).'), array(), WATCHDOG_NOTICE);
}
// Technorati.com
// ----------------------
$result = xmlrpc('http://rpc.technorati.com/rpc/ping', 'weblogUpdates.ping', $name, $url);
if ($result === FALSE) {
watchdog('directory ping', t('Failed to notify Technorati.com (site).'), array(), WATCHDOG_WARNING);
} else {
watchdog('directory ping', t('Successfully notified Technorati.com (site).'), array(), WATCHDOG_NOTICE);
}
// Feedburner.com
// --------------------------
$result = xmlrpc('http://ping.feedburner.google.com', 'weblogUpdates.ping', $name, $url);
if ($result === FALSE) {
watchdog('directory ping', t('Failed to notify Feedburner.com (site).'), array(), WATCHDOG_WARNING);
} else {
watchdog('directory ping', t('Successfully notified Feedburner.com (site).'), array(), WATCHDOG_NOTICE);
}
}
This code will XMLRPC to the three sites and log the event in the database letting you know not only if the ping was unsuccessful, but successful as well.