Community Documentation

hook_ping

5 core.php hook_ping($name = '', $url = '')
6 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

▾ 3 functions implement hook_ping()

drupal_client_ping in modules/drupal/drupal.module
Callback function from drupal_xmlrpc() called when another site pings this one.
MENU_ITEM_GROUPING in includes/menu.inc
Item groupings are used for pages like "node/add" that simply list subpages to visit. They are distinguished from other pages in that they will disappear from the menu if no subpages exist.
ping_ping in modules/ping/ping.module
Implementation of hook_ping().

File

developer/hooks/core.php, line 1047
These are the hooks that are invoked by the Drupal core.

Code

<?php
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);
}
?>
Login or register to post comments