Tutorial & Code: Developing Apps For iPhone/iPad/Android Using Drupal As Base System
on
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:
- Titanium Developer
- iPhone SDK
- Drupal basic installation
- Services Module
- Modified Version of json_server module
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:
http://drupalcon.tut2tech.com/services/json
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.
- JS SHA256 Library This could be useful with key authentication method (in Services API core)
- Javascript function to create a XMLRPC request:
| Attachment | Size |
|---|---|
| json_server_modified.zip_.txt | 10.9 KB |
| Resources.zip_.txt | 1.37 MB |
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
Thanks
Gregg
.......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
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
Sumit,
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.
Regards,
Thomas
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;
Ti.API.info(node);
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() {
Ti.API.info(this.responseText);
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.
Cheers,
Leo
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!
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.
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.
Do you have a sample on how to use authentication?