Date post: | 10-May-2015 |
Category: |
Documents |
Upload: | drupalcampatlanta2012 |
View: | 934 times |
Download: | 0 times |
Talking to Web ServicesThe outside world from Drupal
David BassendineSenior Developer
Me
Day: Mediacurrent
Night: Science & Sustainability
@dbassendine
linkedin.com/in/dbassendine
"Web Services"
open data: science, gov. & development
business tools: customers, pm, seo
social: the big conversation
... (very) big data (and growing)
compfight.com
monitter.com
http://goo.gl/bCkJf
http://goo.gl/gkuDS
agilezen.com
campaignmonitor.com image:http://goo.gl/qlQQ8
The task ahead ...
Creative Commons (CC BY 2.0) by Flickr user mariachily http://goo.gl/iU8aI
http://reverb.echo.nasa.gov/
agilezen.com
Is there a module for that?
Step 0
HTTP and REST
Step 1
1: HTTP Comm.s
1: HTTP Comm.s
1: REST architectures
REST SOAP (XMLRPC)
Resources URIs Custom (data packet)
Methods HTTP verbs Custom (data packet)
Errors HTTP codes Custom (data packet)
Data encoding JSON / XML XML
Consistent*, chatty Flexible but inconsistent
REST for your wife: http://tomayko.com/writings/rest-to-my-wife
REST hypermedia: http://martinfowler.com/articles/richardsonMaturityModel.html
REST vs/ SOAP: http://en.wikipedia.org/wiki/Representational_state_transfer
API Documentation
Step 2
URLs and path structure
Authentication
Resources
Data formats
2: API Documentation
Agile Zen ECHO
URL Structure RESTful RESTful
Authentication Required: Header or Parameter token
Not required for search
Resources Stories, Projects ... Datasets, Granules...
Data formats JSON XML JSON/XML (GET) XML AQL (POST)
dev.agilezen.com http://goo.gl/b38dJ
Test in the browser
Step 3
GET test (simple URL) – eg. http://goo.gl/XUFtn
POSTer test (browser plugin) – Chrome: XHR POSTer – Firefox: Poster
Plan the approach
Step 4
4: Approaches
Drupal core HTTP http://goo.gl/pnML8
REST API Query API drupal.org/project/
rest_api_query
Services Clientdrupal.org/project/
services_client
Feeds (GET only)drupal.org/project/feeds
4: Approaches
Now start to code ...
Step 5
Drupal core HTTP
Drupal 7
Demo: NASA ECHO API
Reason for approach: REST but requires XML
Step 5a
Code: http://drupal.org/sandbox/dbassendine/1829568
Drupal core HTTP
Pros
Flexible
Cons
More code (169 lines)
Encoding / decoding not inc.
Less structural consistency
Step 5a
Encoding / decoding not inc.Well structuredrequest/response
5a: ECHO API
Demo: ECHO API
REST API Query API
Drupal 6 (Open Atrium)
Service: Agile Zen API
Reason for approach: REST and supports JSON
Step 5b
Code: http://drupal.org/sandbox/dbassendine/1828082
REST API Query API
Pros
Less code (114L)
Cons
No XML support
Encoding / decoding inc. Assumptions
More structural consistency
Step 5b
5b: Agile Zen API
Demo: Agile Zen API
Creative Commons (CC BY 2.0) by Flickr user Paxson Woelber http://goo.gl/MYPeM
Where next?
Rules
Logging
Job Scheduler
Views w/ Data module
Queue
Triggers Internal Export
Core hooks
Skills & resources
SimpleXML http://goo.gl/IvaKX (php.net)
HTTP protocol http://www.jmarshall.com/easy/http
REST http://rest.elkstein.org
json_encode/decode http://goo.gl/lKHZ (php.net)
Drupal core HTTP http://goo.gl/pnML8 (d.o)
Drupal REST API Query API drupal.org/project/rest_api_query