iPhone, Drupal and Web Services at DrupalCon SF 2010

 

iPhone, Drupal and Web Services by Kyle Browning, Senior Engineer at WorkHabit. He's been working with Drupal since version 5, and doing work with the iPhone for the last year.

Drupal really needs an entry point into the iPhone market, so our users can utilize the information that Drupal provides on the go. Drupal needs an easy path to share information through the iPhone, Cocoa, the iPad and all that. I want to bridge the gap between Drupal and the iPhone.

Build bridges instead of walls and you will have a friend.
-anonymous

Drupal Modules: Services & Others

There's a new module called Plist, which works just like the XML/RPC server or the JSON server; it basically returns a property list. There's also a library called KBDrupalConnect.

Property lists are basically XML. They allow for arrays, strings and boolean values.

Why not use XML/RPC?

  • XML parsing on the iPhone is slow
  • It uses a lot of battery power
  • By using property lists we can automatically view information in Cocoa

It's Really Easy

It all extends from a main connection class, KBDrupalConnect. You can extend this to write your own methods, and it uses Cocoa notifications.

You can attach yourself to a notification center in Cocoa, and it will ping you when that notification occurs.

Demo

[Kyle gave a demo of a Drupal site shown on an iPad simulator]

What's been built?

  • KBDrupalViews
  • KBDrupalNode
  • KBDrupalUser
  • KBDrupalSearch

What needs to get built?

  • KBDrupalFile
  • KBDrupalMenu
  • KBDrupalComment
  • KBDrupalTaxonomy

You can find the project on github at:
http://github.com/kylebrowning/KBDrupalConnect

Q & A

Q: What are some good Cocoa resources?

A: Try the book, Cocoa Programming for Mac OS X and the iPhone Developer Library is very good.

Q: Do you send the username and password on each call?

A: No, the session ID is stored.

Q: Is the session stored for the lifetime of the app?

A: Sometimes, I can close the app and still have the same session ID. I haven't looked into it that much, but I think it persists.

Q: Have you looked at Oauth?

A: It's hard, because you have to write an authentication service for Drupal. I really want to solve that problem, and figure out a way to get OAuth into Drupal Web Services, but I haven't been able to figure out a way to do it. I'm a huge proponent of OAuth, I love it.

Q: What are your thoughts on the transition from Services 2 to Services 3?

A: We have to move with the technology and keep things up to date. I haven't looked at Services 3, but I definitely will.

Q: Do you recommend using caching?

A: There is no caching right now. It's up to you. There are methods that you can use to save data, particularly write to a file from nsDictionary.

Q: What's the licensing?

A: GPL v2

Q: Any thoughts of changing that to something more commercial?

A: I don't know a lot about licensing, I need to talk to some more people about it. We're trying to find something that we could change it to.

Q: Is there anything similar in the Android space?

A: I haven't seen one. There's a big push for iPhone with Drupal, but not as much with Android. I would love to see someone implement one, that would be great.

You can find more information on Kyle's website, http://kylebrowning.com. Thanks for the presentation!

Did you enjoy this post? Please spread the word.