/[drupal]/contributions/modules/restapi/restapi_services.module
ViewVC logotype

Contents of /contributions/modules/restapi/restapi_services.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Mar 19 20:44:05 2008 UTC (20 months, 1 week ago) by hanenkamp
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
* I've rewritten parts of the API to make new modules easier to write (and so that the central REST API module actually helps a bit more).
* I've added a module for Services support and a helper for Login.
* The main REST API module and REST API User module have been tested a bit more.
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Provides the Services module via this REST API.
7 */
8
9 #/**
10 # * Implements hook_server_info().
11 # */
12 #function restapi_services_server_info() {
13 # return array(
14 # '#name' => 'REST API',
15 # '#path' => 'restapi',
16 # );
17 #}
18 #
19 #/**
20 # * Implementation of hook_server().
21 # */
22 #function restapi_services_server() {
23 #}
24
25 /**
26 * Implements hook_restapi_menu(). Adds the services callbacks.
27 */
28 function restapi_services_restapi_menu($may_cache) {
29 if ($may_cache) {
30 $items[] = array(
31 'method' => 'GET',
32 'path' => '=/service',
33 'callback' => 'restapi_services_do_list',
34 );
35 }
36
37 elseif (arg(0) == '=' && arg(1) == 'service' && arg(2)) {
38 $items[] = array(
39 'method' => 'GET',
40 'path' => '=/service/'.arg(2),
41 'callback' => 'restapi_services_do_describe',
42 );
43
44 $items[] = array(
45 'method' => 'POST',
46 'path' => '=/service/'.arg(2),
47 'callback' => 'restapi_services_do_call',
48 );
49 }
50
51 return $items;
52 }
53
54 function restapi_services_do_list() {
55 $services = services_get_all();
56 $listed_services = array();
57 foreach ($services as $service) {
58 $listed_services[] = $service['#method'];
59 }
60 return restapi_serialize($listed_services);
61 }
62
63 function restapi_services_do_describe($data, $method) {
64 $service = services_method_get($method);
65 if ($service) {
66 return restapi_serialize($service);
67 }
68 else {
69 return drupal_not_found();
70 }
71 }
72
73 function restapi_services_do_call($data, $method) {
74 return restapi_serialize(services_method_call($method_name, $data));
75 }

  ViewVC Help
Powered by ViewVC 1.1.2