Last updated 9 January 2014. Created on 25 July 2011.
Edited by jhodgdon, joachim. Log in to edit this page.

The Clients module provides the ability to implement pluggable clients to external web services, including external Drupal sites running the Services module.

Clients module allows you to create connections to remote services with an admin UI. These handle fetching a result from a remote service. Different types of connection are provided for different types of services. There is a Drupal client connection type for different versions of Services (5.x-0.92, 6.x-2.x, 7.x-3.x), hence Clients can be used to connect to sites with different versions of Drupal.

Connections can be exported to Features. The UI also provides a system for testing connections are correctly set up and functioning.

Installation

Clients requires the following modules:

After installing Clients and the above modules as normal, you can add connections at admin >> build >> clients.

Creating connections

The way in which a connection stores its credentials (such as username and password) is handled by a plugin. This allows connections to store their credentials in different ways. Two credentials storage plugins currently exist:

  • Configuration storage: This works the same as before the introduction of the plugins. The credentials are stored in the connection's configuration array. This means they are exported to features. Use this storage for the convenience of the credentials being in the codebase, and therefore easily available to all developers on a project.
  • Variable storage: The credentials are stored in a system variable. This means they are not exported to features as part of the connection. Use this storage when the credentials should be kept secure and not distributed in the codebase.

Using the API

Each client connection is uniquely identified by its machine name. To call a method on a connection, do:

  $result = clients_connection_call('my_connection', 'the_method.name', $param1, $param2, $param_etc);

So for example, to load a node from a remote Drupal site, do:

  $node = clients_connection_call('my_connection', 'node.get', $remote_nid);
  // Note that the $node will be an array.

If you need to make several calls, you can use the connection object yourself:

  $connection = clients_connection_load('my_connection');
  $result = $connection->callMethod('method.name', $param1, $param2, $param_etc);

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.