Uploaded on

Web services are a treasure trove of tools, content and data. I'll be exploring how we can use Drupal's frameworks to tap into these services. From strategy and selecting the right approach, to …

Web services are a treasure trove of tools, content and data. I'll be exploring how we can use Drupal's frameworks to tap into these services. From strategy and selecting the right approach, to triggering, encoding and sending HTTP messages, I'll walk through how you might go about writing a custom integration that puts your Drupal build into a conversation with the outside world. I'll follow up with real world examples I've built to interact with NASA's ECHO Earth science data service (http://earthdata.nasa.gov/echo) and the Agile Zen project management tool (http://agilezen.com).

Sandboxes for the code demoed in this session are available at:
* ECHO - http://drupal.org/sandbox/dbassendine/1829568
* AgileZen - http://drupal.org/sandbox/dbassendine/1828082

Presented by David Bassendine on 10/27/2012 at Drupalcamp Atlanta (https://www.drupalcampatlanta.com/session/talking-web-services).

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Talking to Web Services The outside world from Drupal
  • 2. Me David Bassendine Senior Developer Day: Mediacurrent Night: Science & Sustainability @dbassendine linkedin.com/in/dbassendine
  • 3. "Web Services"open data: science, gov. & developmentsocial: the big conversationbusiness tools: customers, pm, seo... (very) big data (and growing)
  • 4. compfight.com
  • 5. monitter.com
  • 6. http://goo.gl/bCkJf
  • 7. http://goo.gl/gkuDS
  • 8. agilezen.com
  • 9. campaignmonitor.com image:http://goo.gl/qlQQ8
  • 10. The task ahead ...
  • 11. Creative Commons (CC BY 2.0) by Flickr user mariachily http://goo.gl/iU8aI
  • 12. http://reverb.echo.nasa.gov/
  • 13. agilezen.com
  • 14. Step 0Is there a module for that?
  • 15. Step 1HTTP and REST
  • 16. 1: HTTP Comm.s
  • 17. 1: HTTP Comm.s
  • 18. 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 inconsistentREST vs/ SOAP: http://en.wikipedia.org/wiki/Representational_state_transferREST for your wife: http://tomayko.com/writings/rest-to-my-wifeREST hypermedia: http://martinfowler.com/articles/richardsonMaturityModel.html
  • 19. Step 2API DocumentationURLs and path structureAuthenticationResourcesData formats
  • 20. 2: API Documentation Agile Zen ECHOURL Structure RESTful RESTfulAuthentication Required: Header or Not required for search Parameter tokenResources Stories, Projects ... Datasets, Granules...Data formats JSON XML JSON/XML (GET) XML AQL (POST) dev.agilezen.com http://goo.gl/b38dJ
  • 21. Step 3Test in the browserGET test (simple URL) – eg. http://goo.gl/XUFtnPOSTer test (browser plugin) – Chrome: XHR POSTer – Firefox: Poster
  • 22. Step 4Plan the approach
  • 23. 4: Approaches Drupal core HTTP http://goo.gl/pnML8 REST API Query API drupal.org/project/ rest_api_query Services Client drupal.org/project/ services_client Feeds (GET only) drupal.org/project/feeds
  • 24. 4: Approaches
  • 25. Step 5Now start to code ...
  • 26. Step 5aDrupal core HTTPDrupal 7Demo: NASA ECHO APIReason for approach: REST but requires XMLCode: http://drupal.org/sandbox/dbassendine/1829568
  • 27. Step 5aDrupal core HTTPPros ConsFlexible More code (169 lines)Well structured Encoding / decoding not inc.request/response Less structural consistency
  • 28. 5a: ECHO API
  • 29. Demo: ECHO API
  • 30. Step 5bREST API Query APIDrupal 6 (Open Atrium)Service: Agile Zen APIReason for approach: REST and supports JSONCode: http://drupal.org/sandbox/dbassendine/1828082
  • 31. Step 5bREST API Query APIPros ConsLess code (114L) No XML supportEncoding / decoding inc. AssumptionsMore structuralconsistency
  • 32. 5b: Agile Zen API
  • 33. Demo: Agile Zen API
  • 34. Creative Commons (CC BY 2.0) by Flickr user Paxson Woelber http://goo.gl/MYPeM
  • 35. Where next?Triggers Internal ExportCore hooks Logging Views w/ Data moduleRules Job Scheduler Queue
  • 36. Skills & resourcesHTTP protocol http://www.jmarshall.com/easy/httpREST http://rest.elkstein.orgSimpleXML http://goo.gl/IvaKX (php.net)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