Tutorial & Code: Developing Apps For iPhone/iPad/Android Using Drupal As Base System

Sumit Kataria
Sumit Kataria


May 2, 2010

Tutorial & Code: Developing Apps For iPhone/iPad/Android Using Drupal As Base System

Last week I posted some initial resources related to my DrupalCon San Francisco session Developing Apps for iPhone/iPad/Android using drupal as Base System.

Here is what you need to connect your Drupal site to Titanium App:

For this tutorial I have installed services API and modified version of json_server module over http://drupalcon.tut2tech.com/ so that my json server call URL is:

Note: I am not using any authentication method for this tutorial.

Code to connect Titanium with Drupal and making a call for "pages_list" view will be:
This same code is used in demo application attached to this blog, please download and follow instructions as per above video - you need to replace resources folder of your newly created application with one attached to this blog.
Reason why I modified json_server module's code is also described in video.

Other useful links/code:
  • JS SHA256 Library This could be useful with key authentication method (in Services API core)
  • Javascript function to create a XMLRPC request:
json_server_modified.zip_.txt10.9 KB
Resources.zip_.txt1.37 MB

Share it!

Fantastic tutorial, it's a great insight into where and how to start things. However, I'm also looking for a way to grab CCK data. Any tips or links?Many thanks,Eric
Hello i have followed the above steps to run the application but my application is not launching in the emulator .For running a application , configuration i am using istitanium 1.2.2sdk api 1.6 also tried with api 2.2 alsoIn the titanium, this the info i am getting while launchingit sucessfully launch the application but end up with this info 'application should be running' and the  when i see in emulator its n  
Do you have plans as submitting your changes to json_server as a patch and getting them included into the module?
Good Day To All,  Great read here. I was wondering if there will be a D7 for JSON Server?   Thanks, Mark
I second that!
your sample worked great for me, and i was able to get a view from my own site as well.  however, when i try to use menu.get, i keep getting an access denied" error.  i can call it from the services admin in drupal just fine, but when i build the iphone application, it doesn't work.  has anyone else experienced this? i'm running services 6.x-2.4 with your modified version of  json_Server( 6.x-2.0-alpha1).thanks!-pete
so my issue wasn't with the webservice, it was with drupal permissions.  once i updated them, it worked just fine.if anyone out there gets an access denied error, id go back and check your permissions on each of the services you are trying to invoke.thanks!-pete
Has anyone figured out the issue with node.save?
I try the same code on my local virtualhost, but i recibed the log "Connection to http://drupal6.net refused" .... any idea???
Can someone please advise on how to upload images from photo gallery to drupal backend?
Hi Sumit,Would you please be able to post examples for node.get and node.save?The views.get code in this post works great and I am trying to achieve the same results with node.get and node.save but am not having much luck.Thank you!!!Robert

If you have a linux distro that ships with php 5.1.x like me, and you don't want to upgrade php. You can use this JSON wrapper I found, located here:http://www.boutell.com/scripts/jsonwrapper.html

Woot Drupal iPhone/Android apps with php 5.1.x!


Hope it helps someone, Thanks again Sumit


it appears I need php 5.2.x in order to use json_encode/decode :O

This bit of a code is great, I really appreciate you sharing this. I got this totally working on one of my sites, on another site I copy my services folder entirely and don't receive this prompt when I go to /services/json:

{"#error":true,"#data":"JSON server accepts POST requests only.


the site where I don't get the prompt is in a subdomain (cause It's in development), is this why I can't get it to work? If so, where would I change that in the code?

Anyhow, much appreciated!

In thinking about this a bit more, it would be really great if you could post a "Kitchen Sink" for Drupal package consisting of the code you used in either the initial youtube video you posted or the app you demonstrated during the SF2010 presentation. It would be awesome to be able to look into how you structured your code to access videos, images, map points , save a node etc from Drupal views using services. This will allow us to answer a lot of our own questions by looking into your code rather than inundating you with questions :)

Just a thought



I've been looking forward to checking out the drupal 'kitchen sink' demo code for some time. i was expecting it to be released shortly after your wicked drupalcon sf demo. curious to know what the holdup is?please share the code - release early and release often, i promise i'll contribute back :)

.......phonegap which has also been approved by apple to build apps with.

....but be warned, your app (whether you use Titanium or Phonegap) can't just consist of "web views", Apple will not approve apps like these as this is classed as "web app" and not a "native app".

Look forward to your future tutorials and will keep an eye on your site. Keep up the great work.

Thanks again

This is such a useful article that I would give a huge +1 to turning into a series of articles on this topic covering some more advanced elements including the how to get node.save and cck fields working through titanium. Thanks for your awesome pioneering work with this stuff, its very exciting where it can all go from here. Thanks Gregg
Thanks for your nice words Gregg, I may post some more tutorials in coming weeks!

I don't know much about titanium,i m just programer wanted to make website ipad compatible which at present make in using joomla, plz can u help me to explain how can i start making ipad apps//

Really i have been search this for last 3 week but didn't get any hind or any detail.. of how usatoday is being made..

plz help me out




I don't know much about titanium,i m just programer wanted to make website ipad compatible which at present make in using joomla, plz can u help me to explain how can i start making ipad apps//

Really i have been search this for last 3 week but didn't get any hind or any detail.. of how usatoday is being made..

plz help me out






I'm having trouble getting cck fields into my app.  They are included in the call result when I test views.get on the Services Admin page.  However, the cck fields are not present in the call result within Titanium.   Things like "node_title" and "users_name" show up fine, however.





Do you know how to use the node.save method via a JSON server, I have the following code but the node is not getting posted to my test site.

var node = new Object;

node.method = 'node.save';

node.type = 'story';

node.title = 'Created by android';

node.body = 'Bla bal bal bal';

node.uid = 1;

node.name = 'admin';

node.nid = 0;

node.status = 1;




var xhrsave = Titanium.Network.createHTTPClient();

xhrsave.open("POST", url);

xhrsave.send({data: JSON.stringify(node)});


I have tried the same code as Rudy and hit the same problem.

Debugging provides no useful feedback as to what is going on.


If I try to capture a response using

xhr.onload = function() {

The titanium logger returns:

[INFO] <null>


Can anyone help with code that works for node.save or just a way to improve logging of what the server is actaully responding? 

An example for saving data back to Drupal would be a great 'part two' follow up to this really useful post.



Hey thanks for this. I'm trying to pull a bunch of geo data from a view that I have and plot the points on a map. I can see in your example how you can create annotations and pass each one into the mapView but I can't figure out what it looks like to get them programmatically and plot them on the map. I am able to get the longitude and latitude from the views.get call but not sure where to go from there. Any help is greatly appreciated! Thanks!


Here is working code for adding annotations to your map:
var me = [];
  for (var i = 0; i < data.length; i++) {
    me[i] = Titanium.Map.createAnnotation({
        subtitle:'Mountain View, CA',
        leftButton: 'images/appcelerator_small.png',

Thanks so much Sumit - mapview.addAnnonations() was what was missing.

Is this using Services 2.x or 1.x version? I am using 2.x with JSON server 2.x and I have problems passing arguments to views.get, see http://drupal.org/node/252783.

This is using Services 2.x and passing arguments to views is working fine for me.
Is that true that Apple policies say you can't use Titanium or any other cross compiping technologies any more?
Well can't say anything with 100% surety but more than 50 apps(done with Titanium) have been approved by apple in past 3 weeks ... more details here: http://developer.appcelerator.com/blog/2010/04/steve-jobs-and-adobe-flas... It just looks like a war between Apple and Flash/Adobe at the moment.

I just wanted to point out that I have recently taken over maintainership of JSON Server module and we hope to have a stable release out shortly. I am aware that the current release has several show-stopping problems, and I really want to help get those sorted out as quickly as possible in order that the Services community can continue to use it. 

Hi Heyrocker, Thanks a bunch for taking care of this :)

Do you have a sample on how to use authentication?