ping.module with extendedPing for Drupal

In recent post, I made a patch for configurable ping.module. Anyway, some ping servers don"t accept simple ping, instead they preferred extendedPing. For example, blo.gs.

diff -u ping.module ping.module
--- ping.module.orig 2005-12-31 21:18:22.000000000 +0700
+++ ping.module 2006-01-27 15:00:35.000000000 +0700
@@ -44,6 +44,32 @@
}

/**
+ * Implemetaion of hook_settings
+ */
+function ping_settings() {
+ $form["ping"] = array(
+ "#type" => "fieldset",
+ "#title" => t("Ping settings"),
+ "#collapsible" => TRUE,
+ );
+ $form["ping"]["ping_pinger_list"] = array(
+ "#type" => "textarea",
+ "#title" => t("URLs to ping"),
+ "#default_value" => variable_get("ping_pinger_list", "http://rpc.pingomatic.com"),
+ "#width" => 40,
+ "#height" => 10,
+ );
+ $form["ping"]["ping_extended_pinger_list"] = array(
+ "#type" => "textarea",
+ "#title" => t("URLs to extended ping"),
+ "#default_value" => variable_get("ping_extended_pinger_list", ""),
+ "#width" => 40,
+ "#height" => 10,
+ );
+ return $form;
+}
+
+/**
* Call hook_ping() in all modules to notify remote sites that there is
* new content at this one.
*/
@@ -58,11 +84,32 @@
*/
function ping_ping($name = "", $url = "") {

- $result = xmlrpc("http://rpc.pingomatic.com", "weblogUpdates.ping", $name, $url);
+ $pingers = explode("\n", variable_get("ping_pinger_list", "http://rpc.pingomatic.com"));
+ foreach ($pingers as $pinger) {
+ $pinger = trim($pinger);
+ if (empty($pinger)) {
+ continue;
+ }
+ $result = xmlrpc($pinger, "weblogUpdates.ping", $name, $url);
+
+ if ($result === FALSE) {
+ watchdog("directory ping", t("Failed to notify %pinger (site). %message", array("%pinger" => $pinger, "%message" => xmlrpc_error_msg())), WATCHDOG_WARNING);
+ }
+ }

- if ($result === FALSE) {
- watchdog("directory ping", t("Failed to notify pingomatic.com (site)."), WATCHDOG_WARNING);
+ $pingers = explode("\n", variable_get("ping_extended_pinger_list", ""));
+ foreach ($pingers as $pinger) {
+ $pinger = trim($pinger);
+ if (empty($pinger)) {
+ continue;
+ }
+ $result = xmlrpc($pinger, "weblogUpdates.extendedPing", $name, $url, "", "$url/rss.xml");
+
+ if ($result === FALSE) {
+ watchdog("directory ping", t("Failed to notify %pinger (site). %message", array("%pinger" => $pinger, "%message" => xmlrpc_error_msg())), WATCHDOG_WARNING);
+ }
}
}


+?>

Technorati Tags: , , , ,

Post new comment