1 | * What it does |
---|
2 | |
---|
3 | services_views in combination with the Services module version 3.x and later |
---|
4 | allows you to access and retrieve views via a service endpoint. |
---|
5 | |
---|
6 | * Prerequisites |
---|
7 | |
---|
8 | Services module version 3.x and later is a dependency and you should read up |
---|
9 | about the different service callbacks available from that module and how to set |
---|
10 | up endpoints and resources. |
---|
11 | |
---|
12 | * Configuring with an endpoint |
---|
13 | |
---|
14 | Once you have an endpoint set up, visit the resources section of the endpoint |
---|
15 | and enable the views resource. |
---|
16 | |
---|
17 | * Basic Usage |
---|
18 | |
---|
19 | The most basic usage is http://example.com/my_endpoint/views/view_name which |
---|
20 | will retrieve the whole view. |
---|
21 | |
---|
22 | A useful tool in firefox for testing services in general is the HttpRequester |
---|
23 | addon that lets you do all sorts of CRUD. |
---|
24 | |
---|
25 | A basic example in HttpRequester |
---|
26 | |
---|
27 | 1. |
---|
28 | * URL: http://example.com/my_endpoint/user/login |
---|
29 | * Content type: application/json |
---|
30 | * Content box: {"username":"blah","password":"blahblah"} |
---|
31 | * Click post. |
---|
32 | |
---|
33 | You should get a 200 ok reponse. You are now logged in. |
---|
34 | |
---|
35 | 2. |
---|
36 | * URL: http://example.com/my_endpoint/views/view_name |
---|
37 | * Click get. |
---|
38 | |
---|
39 | You should get a 200 ok response and a nice big blob of json containing your view. |
---|
40 | |
---|
41 | * Arguments and Parameters to Views (limit, offset, args, display_id) |
---|
42 | |
---|
43 | Based on the full details in the module: |
---|
44 | |
---|
45 | services_views_retrieve($view_name, $display_id = 'default', $args = array(), |
---|
46 | $offset = 0, $limit = 10, $return_type = FALSE, $filters = array()) |
---|
47 | |
---|
48 | /** |
---|
49 | * Callback for retrieving views resources. |
---|
50 | * |
---|
51 | * @param $view_name |
---|
52 | * String. The views name. |
---|
53 | * @param $display_id |
---|
54 | * String (optional). The views display name. |
---|
55 | * @param $offset |
---|
56 | * Integer (optional). An offset integer for paging. |
---|
57 | * @param $limit |
---|
58 | * Integer (optional). A limit integer for paging. |
---|
59 | * @param $args |
---|
60 | * Array (optional). A list of arguments to pass to the view. |
---|
61 | * @param $return_type |
---|
62 | * String (optional). Whether to return the raw data results (FALSE), the entire views object ('view') or themed results ('theme'). |
---|
63 | * @param $args |
---|
64 | * Array (optional). A list of exposed filters to pass to the view. |
---|
65 | * |
---|
66 | * @return |
---|
67 | * Array. The views return. |
---|
68 | */ |
---|
69 | |
---|
70 | The arguments are passed in the usual url format, for example: |
---|
71 | http://example.com/my_endpoint/views/view_name?display_id=default&args=123&offset=0&limit=10&return_type=FALSE |
---|
72 | |
---|
73 | Multiple arguments can be used like this: |
---|
74 | http://example.com/my_endpoint/views/view_name?display_id=default&args[0]=abc&args[1]=123&offset=0&limit=10&return_type=FALSE |
---|