You are here

README.txt in Web Service Clients 6.2

Same filename in this branch
  1. 6.2 README.txt
  2. 6.2 connections/clients_drupal/README.txt
Same filename and directory in other branches
  1. 7.3 README.txt
  2. 7 README.txt
  3. 7.2 README.txt
Connections
===========

Clients module provides a simple UI for creating, editing, and testing
connections to remote sites.

Connections are exportable with CTools and thus can be added to Features.

Requirements
============

Clients requires the following modules:

- Autoload
- CTools 6.x-1.x-dev.
  If you'd rather not run a development version, these are the patches to
  6.x-1.0 that Clients needs:
  - http://drupal.org/node/1094014
  - http://drupal.org/node/1146604

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:

  try {
    // 'my_connection' is the machine name of the connection.
    $result = clients_connection_call('my_connection', 'method.name', $param1, $param2, $param_etc);
  }
  catch (Exception $e) {
    // Something went wrong; it's up to you to display an error.
    // This is the error message, if any:
    $message = $e->getMessage();
  }

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

  try {
    $node = clients_connection_call('my_connection', 'node.get', $remote_nid);
    // Note that the $node will be an array.
  }
  catch (Exception $e) {
    drupal_set_message("Error loading a remote node.");
  }

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

  $connection = clients_connection_load('my_connection');
  try {
    $result = $connection->callMethod('method.name', $param1, $param2, $param_etc);
  }
  catch (Exception $e) {
    drupal_set_message("Error calling method.name.");
  }


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.
  - callMethodArray(), which should call a remote method and return the result.

File

README.txt
View source
  1. Connections
  2. ===========
  3. Clients module provides a simple UI for creating, editing, and testing
  4. connections to remote sites.
  5. Connections are exportable with CTools and thus can be added to Features.
  6. Requirements
  7. ============
  8. Clients requires the following modules:
  9. - Autoload
  10. - CTools 6.x-1.x-dev.
  11. If you'd rather not run a development version, these are the patches to
  12. 6.x-1.0 that Clients needs:
  13. - http://drupal.org/node/1094014
  14. - http://drupal.org/node/1146604
  15. Using the Clients API
  16. =====================
  17. The Clients connection object lets you call methods on remote sites very
  18. simply, without having to deal with tokens, keys, and all that sort of
  19. stuff.
  20. Once a connection is defined in the admin UI, you can call a remote method on it
  21. like this:
  22. try {
  23. // 'my_connection' is the machine name of the connection.
  24. $result = clients_connection_call('my_connection', 'method.name', $param1, $param2, $param_etc);
  25. }
  26. catch (Exception $e) {
  27. // Something went wrong; it's up to you to display an error.
  28. // This is the error message, if any:
  29. $message = $e->getMessage();
  30. }
  31. So for example, to load a node from a remote Drupal site, do:
  32. try {
  33. $node = clients_connection_call('my_connection', 'node.get', $remote_nid);
  34. // Note that the $node will be an array.
  35. }
  36. catch (Exception $e) {
  37. drupal_set_message("Error loading a remote node.");
  38. }
  39. If you need to make several calls, you can use the connection object yourself:
  40. $connection = clients_connection_load('my_connection');
  41. try {
  42. $result = $connection->callMethod('method.name', $param1, $param2, $param_etc);
  43. }
  44. catch (Exception $e) {
  45. drupal_set_message("Error calling method.name.");
  46. }
  47. Defining Connection types
  48. =========================
  49. To define your own connection type, you need:
  50. - an implementation of hook_clients_connection_type_info().
  51. - a class definition for your connection type. This should be named
  52. 'clients_connection_YOUR_TYPE_ID' and implement the following methods:
  53. - connectionSettingsForm(), which should return a FormAPI array for your
  54. connection type's edit form.
  55. - connectionSettingsForm_submit(), which should provide any processing of
  56. the form specific to your connection type.
  57. - callMethodArray(), which should call a remote method and return the result.