function hook_ping

6.x core.php hook_ping($name = '', $url = '')

Ping another server.

This hook allows a module to notify other sites of updates on your Drupal site.

Parameters

$name: The name of your Drupal site.

$url: The URL of your Drupal site.

Return value

None.

Related topics

1 function implements hook_ping()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

ping_ping in drupal-6.x/modules/ping/ping.module
Implementation of hook_ping().
1 invocation of hook_ping()
_ping_notify in drupal-6.x/modules/ping/ping.module
Call hook_ping() in all modules to notify remote sites that there is new content at this one.

File

documentation-6.x/developer/hooks/core.php, line 1765
These are the hooks that are invoked by the Drupal core.

Code

function hook_ping($name = '', $url = '') {
  $feed = url('node/feed');

  $client = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80);

  $message = new xmlrpcmsg('weblogUpdates.ping', 
  array(new xmlrpcval($name), new xmlrpcval($url)));

  $result = $client->send($message);

  if (!$result || $result->faultCode()) {
    watchdog('error', 'failed to notify "weblogs.com" (site)');
  }

  unset($client);
}