Drupal Services - Part 1

image

Well, it is that cheerful time of the year again when we celebrate different festivities overloaded with food and benign and not-so-benign drinking.  It is also that time of the year when we start thinking of our New Year resolution(s).  For me, it is about peace and goodwill to mankind, and of course, losing some weight.  So Merry Christmas, Happy Hanukkah, Feliz Navidad, Happy Kwanzaa, Happy Holidays and all that jolly good stuff.  So, what are we blogging about today?  Well, guess what: it is Drupal - again.  This time I’ll be short and brief, as I will venture more into the technicalities when I am more sober and fresh after the holiday season.

The topic today is the Drupal Services module.  This module is such a powerful gem (not related to Ruby on Rails gems) because it allows you to integrate your Drupal Content Management System (CMS) with pretty much any programming language that can talk to a REST Server.  So what is REST?  Well, it is complicated so I am not going to talk about it here but will point to Roy Fielding’s dissertation paper on REST, and specifically chapter five, as he is considered the godfather of Representational State Transfer or more commonly referred to as just REST. So in the Drupal world, you can write a PHP class that interfaces with the Drupal REST Server and using standard HTTP verbs (Get, Post, Put, and Delete) you can CRUD a Drupal node; e.g. a wiki page such as:

  • GET /wiki/entry/add (gets a new wiki form)
  • POST /wiki/entry/add (posts a new wiki node)
  • PUT /wiki/entry/[node id] (edit wiki entry)
  • DELETE /wiki/entry/[node id] (delete wiki entry)

That is a slick functionality because you might have an application and want to expose some of your existing Drupal CMS content types in that system.  Or perhaps you are building a mobile app that also exposes some of those content items; e.g. a listing of job vacancies, news articles, etc. These nodes are stored in Drupal but through the services API and REST are exposed in Java for an Android mobile app and content is returned as standard JSON.  Obviously, you can theme your site to run on different platforms but it is kind of handy and light weight to have a mechanism to retrieve and edit certain Drupal content via REST calls.

I am still getting the ins and outs of the Drupal Services modules and will post a more concrete example on my next blog.

Thanks.

Subscribe to Our Newsletter

Stay In Touch