SVCC Drupal+iPhone

24
Drupal + iPhone = AWESOME Eneko Alonso [email protected] Silicon Valley Code Camp October 2009

description

Presentation on Drupal+iPhone given at Silicon Valley Code Camp 2009 by Eneko Alonso.

Transcript of SVCC Drupal+iPhone

Page 1: SVCC Drupal+iPhone

Drupal + iPhone = AWESOME

Eneko [email protected]

Silicon Valley Code CampOctober 2009

Page 2: SVCC Drupal+iPhone

Eneko AlonsoI am a Software Engineer and UI Developer,

currently working at Level Studiosealonso@level-studios.comwww.level-studios.comwww.enekoalonso.com

Eneko [email protected]

Page 3: SVCC Drupal+iPhone

DRUPAL

Eneko [email protected]

Page 4: SVCC Drupal+iPhone

Drupal: what is it?

• Content Management System• Community (user management, roles,

permissions)• Base for great web applications

Check out www.drupal.org

Eneko [email protected]

Page 5: SVCC Drupal+iPhone

iPhone

Eneko [email protected]

Page 6: SVCC Drupal+iPhone

iPhone: what is it?

Eneko [email protected]

Page 7: SVCC Drupal+iPhone

Drupal + iPhoneWhy?

Eneko [email protected]

Page 8: SVCC Drupal+iPhone

Drupal+iPhone: why?

Let your users access your site on the goBut also, great for administration

Eneko [email protected]

Page 9: SVCC Drupal+iPhone

Setup: what do we need?

Eneko [email protected]

Page 10: SVCC Drupal+iPhone

Drupal: what we need

Drupal site:• [X]AMP Server (PHP, Apache, MYSQL)• Drupal distribution (6.14 in this demo)

JSON API:• Services Module• JSON Server Module

Eneko [email protected]

Page 11: SVCC Drupal+iPhone

iPhone: what we need

1. XCode with iPhone SDK (3.0 on this demo)2. TouchJSON library

http://developer.apple.com/iphone/http://code.google.com/p/touchcode/wiki/TouchJSON

Eneko [email protected]

Page 12: SVCC Drupal+iPhone

iPhone: what we don’t need

1. iPhone Developer License*

* Needed only to put your app in your iPhone for testing.

http://developer.apple.com/iphone/http://code.google.com/p/touchcode/wiki/TouchJSON

Eneko [email protected]

Page 13: SVCC Drupal+iPhone

Setup

Eneko [email protected]

Page 14: SVCC Drupal+iPhone

Create a user account on the site:http://[server_ip]/user/register

Write a new story:http://[server_ip]/node/add/story

On XCode 3.1, create a new iPhone project

Eneko [email protected]

Demo Setup

Page 15: SVCC Drupal+iPhone

Drupal Setup

1. Create DB: CREATE DATABASE drupal_iphone_demo;

2. Download drupal: wget http://drupal.org/…

3. Install drupal (browse to your server url)4. Install and enable modules (Services)5. Configure user permissions

Eneko [email protected]

Page 16: SVCC Drupal+iPhone

iPhone Setup

1. Create new Project2. Add JSON library to project (TouchJSON)3. Add a button to the view4. Add a method for system.connect5. Execute server request and show data on

console

Eneko [email protected]

Page 17: SVCC Drupal+iPhone

API Calls

Eneko [email protected]

Page 18: SVCC Drupal+iPhone

system.connect

Initiates user sessionServer returns valid sessionId for login

Eneko [email protected]

Page 19: SVCC Drupal+iPhone

user.login

Logs user into DrupalSame user permissions as on the site

Eneko [email protected]

Page 20: SVCC Drupal+iPhone

node.get

Retrieves a full node from the server

Eneko [email protected]

Page 21: SVCC Drupal+iPhone

node.save

Saves changes or creates a new node

Eneko [email protected]

Page 22: SVCC Drupal+iPhone

views.get

Collection of nodes (great for table views)

Eneko [email protected]

Page 23: SVCC Drupal+iPhone

Creating custom services

Eneko [email protected]

Page 24: SVCC Drupal+iPhone

myservice.hello

Let’s create a ‘Hello world’ service

Eneko [email protected]