drupal web services

34
Drupal Web Services Darren Mothersele

Upload: darren-mothersele

Post on 29-Nov-2014

6.151 views

Category:

Documents


3 download

DESCRIPTION

 

TRANSCRIPT

Drupal Web Services

Darren Mothersele

Drupal Web Services

Uses of web services

Classifications of web services

Example web service

Types of web services in Drupal

WebsitesWeb apps

Websites, web apps +

SyndicationInteroperabilityOutsource complexityReuse application componentsMashups and unforeseen...

FlickrGoogle AdWordsGoogle Mapshostip.infoNOAA Weather ServiceYahoo GeocodingYahoo Local Search

iPhone app

Classification of web services

XML-RPC

REST - resource oriented approach...

Method information goes in the HTTP method

Scoping information goes in the URL

HTTP methods

HTTP error codes

If you get 200 then all is ok.

If you get 3xx 4xx 5xx then something went wrong.

3xx = it's moved4xx = client error 5xx = server error

404 = not found418 = i'm a teapot 500 = internal server error503 = service unavailable

REST example - Amazon S3

Amazon S3 based on two concepts:

Bucketname

Objectparent bucketvalue (the data)key (name)metadata (key/value pairs)

REST example - Amazon S3

Resources:

List of your bucketshttp://s3.amazonaws.com/

A buckethttp://s3.amazonaws.com/{bucketname}/

An objecthttp://s3.amazonaws.com/{bucketname}/{objectname}

REST example - Amazon S3

Methods:

Types of web service in Drupal

Views Datasource(read only)

Views Atom(read only)

Services v3 Services v2

Blog API

Views Datasource

Multiple data formats RDF, XML, JSON,

Configurable using awesome power of Views...

http://tagging.darrenmothersele.com/node/42/

http://tagging.darrenmothersele.com/node/42/json

Views Atom

Style plugin Alternative Feed style that generates Atom not RSS

RDFNode Row style plugin Serializes arbitrary node to XML, including CCK fields

Useful with Feeds Atom to move content between Drupal sites.

http://tagging.darrenmothersele.com/node/42/atom

Services v3 - the futureFully RESTful web services now possible in Drupal

REST on a node

CRUD

create: POST /noderead: GET /node/1 index: GET /nodeupdate: PUT /node/1delete: DELETE /node/1

Services 3 extensions to CRUD

Actions, eg:

POST /node/publish_my_drafts

Targeted actions, eg:

POST /node/1/publish

Relationships, eg:

GET /node/1/comments

Response formats

XMLRPC returns XMLJSONRPC returns JSON

REST format agnostic:

http://example.com/node/1.xml returns XMLhttp://example.com/node/1.json returns JSONhttp://example.com/node/1.php returns serialized-PHP

Links

Serviceshttp://drupal.org/project/servicesViews Datasourcehttp://drupal.org/project/views_datasourceViews Atomhttp://drupal.org/project/views_atomHyper Text Coffee Pot Control Protocol (HTCPCP/1.0)http://tools.ietf.org/html/rfc2324