You are here

README.txt in Services Client 7

Same filename in this branch
  1. 7 services_client_connection/README.txt
  2. 7 services_raw/README.txt
Same filename and directory in other branches
  1. 7.2 services_client_connection/README.txt
Services Client Connection
==========================

Provides extendable API for talking to remote Drupal site via services and UI 
for configuring connections to remote sites. Module allows to define multiple
connections with different attributes to one or multiple sties. Connections
can be exported either via hook or using features.

Dependencies

* ctools
* PHP cURL extension

Architecture
============

This module aims to create general API for connecting to remote site. To achieve
that it uses ctools plugin system. Each connection consits of class with three
plugins. API user shouldn't take care of any aspect of creating requests and
parsing responses. Each plugin can have own configuration (similar to Feeds module).

* Authentication

Ensures that requests to remote site will be authenticated. Currently there are two
available methods:
 
 * Session authentication
 * OAauth (requires OAuth api module)

* Server plugin

Server plugin formats request for remote services server i.e. REST or XML-RPC. By
default module comes with two plugins. Server also parses response from remote Drupal
site and translate data from text form to PHP structures. Supported remote servers:

 * XML-RPC server
 * REST server (allow to communicate via JSON for example)

* Request plugin

Request handles HTTP connection to remote server, sending data and getting HTTP resposne.
Server is responsible for interpreting low-level HTTP status codes and to generate
exception if connection failed for some reason. Supported is cURL 

Usage
=====

Connection can be defined via administration UI and referenced by name or manually
by passing configuration array in PHP.

1. Configure new connection
   admin/structure/services_client/connection

   - Administration title
   - Description
   - Remote services version
   - Endpoint - remote site URL 
   - Plugins - Autentication, Server, Request

2. Configure each plugin
   admin/structure/services_client/connection/list/[machine_name]/auth
   admin/structure/services_client/connection/list/[machine_name]/server
   admin/structure/services_client/connection/list/[machine_name]/request

Each connection can be exported to code either manually using
  
   hook_services_client_connection_default_connections();

or with Features module.

After connection is defined either in DB or in hook can be initialized with
services_client_connection_get.

   $api = services_client_connection_get('machine_name');
   $node = $api->get('node', 14);
   $node['title'] = 'New title';
   $api->update('node', 14, $node);

Since connection to remote site can be unsucessfull because of many different problem
like network, authenticaton or site issues Services Client Connection raises 
ServicesClientConnectionResponseException . Exception contains all request and response
data. Example:

   try {
     $api = services_client_connection_get('machine_name');
     $node = $api->get('node', 14);
     $node['title'] = 'New title';
     $api->update('node', 14, $node);
   }
   catch (ServicesClientConnectionResponseException $e) {
     $e->log();
   }

In example log method is used which write request and response to watchdog as
'scc' type and error severity. If custom handling is required exception provides
public attributes $e->request and $e->response.

ServicesClientConnection class provides methods that should cover every request
to remote drupal site running services 3.x.

   * index
   * create
   * update
   * get (retrieve)
   * delete
   * targetAction
   * relationships
   
Developers
==========

Hooks documentation is available in services_client_connection.api.php. Examples how 
to write plugins are in services_client_connection.module.

File

services_client_connection/README.txt
View source
  1. Services Client Connection
  2. ==========================
  3. Provides extendable API for talking to remote Drupal site via services and UI
  4. for configuring connections to remote sites. Module allows to define multiple
  5. connections with different attributes to one or multiple sties. Connections
  6. can be exported either via hook or using features.
  7. Dependencies
  8. * ctools
  9. * PHP cURL extension
  10. Architecture
  11. ============
  12. This module aims to create general API for connecting to remote site. To achieve
  13. that it uses ctools plugin system. Each connection consits of class with three
  14. plugins. API user shouldn't take care of any aspect of creating requests and
  15. parsing responses. Each plugin can have own configuration (similar to Feeds module).
  16. * Authentication
  17. Ensures that requests to remote site will be authenticated. Currently there are two
  18. available methods:
  19. * Session authentication
  20. * OAauth (requires OAuth api module)
  21. * Server plugin
  22. Server plugin formats request for remote services server i.e. REST or XML-RPC. By
  23. default module comes with two plugins. Server also parses response from remote Drupal
  24. site and translate data from text form to PHP structures. Supported remote servers:
  25. * XML-RPC server
  26. * REST server (allow to communicate via JSON for example)
  27. * Request plugin
  28. Request handles HTTP connection to remote server, sending data and getting HTTP resposne.
  29. Server is responsible for interpreting low-level HTTP status codes and to generate
  30. exception if connection failed for some reason. Supported is cURL
  31. Usage
  32. =====
  33. Connection can be defined via administration UI and referenced by name or manually
  34. by passing configuration array in PHP.
  35. 1. Configure new connection
  36. admin/structure/services_client/connection
  37. - Administration title
  38. - Description
  39. - Remote services version
  40. - Endpoint - remote site URL
  41. - Plugins - Autentication, Server, Request
  42. 2. Configure each plugin
  43. admin/structure/services_client/connection/list/[machine_name]/auth
  44. admin/structure/services_client/connection/list/[machine_name]/server
  45. admin/structure/services_client/connection/list/[machine_name]/request
  46. Each connection can be exported to code either manually using
  47. hook_services_client_connection_default_connections();
  48. or with Features module.
  49. After connection is defined either in DB or in hook can be initialized with
  50. services_client_connection_get.
  51. $api = services_client_connection_get('machine_name');
  52. $node = $api->get('node', 14);
  53. $node['title'] = 'New title';
  54. $api->update('node', 14, $node);
  55. Since connection to remote site can be unsucessfull because of many different problem
  56. like network, authenticaton or site issues Services Client Connection raises
  57. ServicesClientConnectionResponseException . Exception contains all request and response
  58. data. Example:
  59. try {
  60. $api = services_client_connection_get('machine_name');
  61. $node = $api->get('node', 14);
  62. $node['title'] = 'New title';
  63. $api->update('node', 14, $node);
  64. }
  65. catch (ServicesClientConnectionResponseException $e) {
  66. $e->log();
  67. }
  68. In example log method is used which write request and response to watchdog as
  69. 'scc' type and error severity. If custom handling is required exception provides
  70. public attributes $e->request and $e->response.
  71. ServicesClientConnection class provides methods that should cover every request
  72. to remote drupal site running services 3.x.
  73. * index
  74. * create
  75. * update
  76. * get (retrieve)
  77. * delete
  78. * targetAction
  79. * relationships
  80. Developers
  81. ==========
  82. Hooks documentation is available in services_client_connection.api.php. Examples how
  83. to write plugins are in services_client_connection.module.