4. Services
Move from RPC style to REST
REST
GET safe method (only to retrieve)
PUT and DELETE are idempotent methods (multiple
calls should have same result)
5. Services 3.x
resource oriented (CRUD = create, retrieve,
update, delete, index)
Content Type
different formatters (php, json, jsonp, xml, ...)
separate endpoints (exportable to features)
authentication
6. Content Type
Request: URL, headers, body
Content-type: application/x-www-form-urlencoded
key1=value1&key2=value2&key3[0]=a&key3[1]=b&key3[2]=c
Content-type: application/json
{"key1":"value1","key2":"value2","key3":["a","b","c"]}
8. REST with Services
Create POST http://host/rest/node.json
Retrieve GET http://host/rest/node/5.json
Update PUT http://host/rest/node/5.json
Delete DELETE http://host/rest/node/5.json
Index GET http://host.com/rest/node.json
9. REST with Services
Action
POST http://host/rest/user/login.json
Targeted Action
POST http://host/rest/node/5/vote.json
Relation
GET http://host/rest/node/5/files.json
10. Services 3.x resources
Node resource
Taxonomy vocabulary resource (getTree)
Taxonomy term resource (selectNodes)
User resource (login, logout, register)
Comment resource (loadNodeComments,
countAll, countNew)
System resource (no CRUD) (connect,
get_variable, set_variable)
14. Services 3.x REST server formatters
http://<your_domain>/<your_endpoint_path>/<your_resource_path>.<formatter>
Standard: php, json, jsonp, xml, yaml, bencode (see RESTServerViewBuiltIn)
15. Build REST interface
Implement CRUD functionality.
Use actions, relationships
resource/node/X/comments
Use aliases if needed.
Write tests
For public GET calls you can use Views + Views
Datasource