You are here

README.txt in Web Service Clients 7

Same filename in this branch
  1. 7 README.txt
  2. 7 backends/clients_drupal/README.txt
Same filename and directory in other branches
  1. 6.2 README.txt
  2. 7.3 README.txt
  3. 7.2 README.txt
Using the Clients API
=====================

The Clients connection object lets you call methods on remote sites very
simply, without having to deal with tokens, keys, and all that sort of
stuff.

Once a connection is defined in the admin UI, you can call a remote method on it
like this:

  // $connection_id is the ID of the connection.
  $connection = clients_get_connection($connection_id);
  $result = $connection->callMethod('method.name', $param1, $param2, $param_etc);
  
Example: getting a node from a remote site:

  $connection = clients_get_connection($drupal_site_connection_id);
  $node = $connection->callMethod('node.get', $remote_nid);
  // Note that the $node will be an array.

Defining Connection types
=========================

To define your own connection type, you need:

- an implementation of hook_clients_connection_type_info().
- a class definition for your connection type. This should be named
  'clients_connection_YOUR_TYPE_ID' and implement the following methods:
  - connectionSettingsForm(), which should return a FormAPI array for your
    connection type's edit form.
  - connectionSettingsForm_submit(), which should provide any processing of
    the form specific to your connection type.
  - callMethod(), which should call a remote method and return the result.

File

README.txt
View source
  1. Using the Clients API
  2. =====================
  3. The Clients connection object lets you call methods on remote sites very
  4. simply, without having to deal with tokens, keys, and all that sort of
  5. stuff.
  6. Once a connection is defined in the admin UI, you can call a remote method on it
  7. like this:
  8. // $connection_id is the ID of the connection.
  9. $connection = clients_get_connection($connection_id);
  10. $result = $connection->callMethod('method.name', $param1, $param2, $param_etc);
  11. Example: getting a node from a remote site:
  12. $connection = clients_get_connection($drupal_site_connection_id);
  13. $node = $connection->callMethod('node.get', $remote_nid);
  14. // Note that the $node will be an array.
  15. Defining Connection types
  16. =========================
  17. To define your own connection type, you need:
  18. - an implementation of hook_clients_connection_type_info().
  19. - a class definition for your connection type. This should be named
  20. 'clients_connection_YOUR_TYPE_ID' and implement the following methods:
  21. - connectionSettingsForm(), which should return a FormAPI array for your
  22. connection type's edit form.
  23. - connectionSettingsForm_submit(), which should provide any processing of
  24. the form specific to your connection type.
  25. - callMethod(), which should call a remote method and return the result.