SlideShare a Scribd company logo
DRUPAL, ANDROID
  AND IPHONE




     Badiu Alexandru
       Fratu Mihai
    Drupalcamp Bucharest 2011
ABOUT US
•   We work at Adulmec
•   We do fine products such as Dealfever, Urbo and
    Adulmec
•   We sometime build mobile apps
•   Ataxi, Urbo, games and soon the Adulmec app




                Drupalcamp Bucharest 2011
CONNECTI
•   You expose some functionality as
    REST or some sort of web service
•   Your mobile application makes HTTP
    calls
•   Authentication? Access control?


            Drupalcamp Bucharest 2011
CONNECTI
•   Two ways
•   Use the Services module
•   Use a custom solution
•   Depends on your requirements



            Drupalcamp Bucharest 2011
FOR
•   Adulmec Coupon Redeem - custom
•   Urbo - Services




            Drupalcamp Bucharest 2011
CUSTOM
•   Write php pages
•   Without Drupal
•   Lightweight Drupal
•   Full Drupal
•   Output XML or JSON
•   Make HTTP call and parse result

             Drupalcamp Bucharest 2011
CUSTOM
•   Latest news app
•   Shows a list of the latest posts on a
    site
•   Click on a post, go to the site



             Drupalcamp Bucharest 2011
<?php
            CUSTOM
chdir('../');

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$response = array();

$result = db_query_range('SELECT nid, title FROM {node} WHERE type="story" ORDER
BY created DESC', 0, 10);
while ($row = db_fetch_object($result)) {
  $response[] = array('title' => $row->title, 'url' => 'node/' . $row->nid);
}

drupal_json($response);




                          Drupalcamp Bucharest 2011
CUSTOM
[
   {
      "title":"Illum Verto Fere Esse Secundum C
ui Zelus Luctus",
      "url":"node/2"
   },
   {
      "title":"Uxor Eu Camur Voco Refero Fere",
      "url":"node/7"
   },
]



              Drupalcamp Bucharest 2011
CUSTOM
URI uri = new URI("http://0001.ro/alex/drupalcamp/services/pages/list.php");
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(uri);
HttpResponse response = client.execute(request);
InputStream is = response.getEntity().getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String result = br.readLine();


adapter.clear();
JSONArray r = new JSONArray(result);
for (int i = 0; i < r.length(); i++) {
    JSONObject jitem = r.getJSONObject(i);
    SubtitleItem item = new SubtitleItem(jitem.getString("title"),
jitem.getString("url"));
    adapter.add(item);
}
adapter.notifyDataSetChanged();


                         Drupalcamp Bucharest 2011
SERVICES
•   Creates web services out of Drupal
    functions
•   Concepts: service and server
•   Autenthication plugins
•   Pluggable


            Drupalcamp Bucharest 2011
SERVICES
•   Out of the box: Comments, Files,
    Menu, Node, Search, System,
    Taxonomy, User, Views
•   XMLRPC Server
•   Key based authentication


            Drupalcamp Bucharest 2011
SERVICES
•   We use XMLRPC in iOS apps
•   We use JSON in Android apps
•   json_server
•   Demo with standard json parser
•   GSON and Jackson
•   Streaming and mapping

            Drupalcamp Bucharest 2011
SERVICES
•   Drupalcloud for Android
•   Custom code for iOS
•   drupal-ios-sdk



            Drupalcamp Bucharest 2011
SERVICES
•   Key auth allows you to grant access
    just to some specific apps
•   Fine-grained: user authentication
•   Session id is used in every call
•   system.connect


             Drupalcamp Bucharest 2011
SERVICES
•   hash - sha of domain, time and
    nonce
•   domain
•   timestamp
•   nonce
•   session

              Drupalcamp Bucharest 2011
SERVICES
•   call system.connect - get session
•   use session in every call
•   call user.login - get new session
•   use new session in every call
•   call user.logout
•   call system.connect - get session
•   repeat

              Drupalcamp Bucharest 2011
SERVICES
•   What about saving session across app
    launches?
•   Save session and timestamp to prefs
    after login or connect
•   At launch check that the saved session
    has not expired
•   If not, use that session
•   Otherwise system.connect

              Drupalcamp Bucharest 2011
WTFS
•   userLogin returns new session
•   no user uid
•   no way to set it in the client
•   we create our own
•   json_server does not work


             Drupalcamp Bucharest 2011
public void setSessionId(String sessionId) {
  SharedPreferences auth = mCtx.getSharedPreferences(mPREFS_AUTH, 0);
  SharedPreferences.Editor editor = auth.edit();
  editor.putString("sessionid", sessionId);
  editor.putLong("sessionid_timestamp", new Date().getTime() / 100);
  editor.commit();
}




                      Drupalcamp Bucharest 2011
WTFS
    •   Services is inconsistent or weird
    •   You’re already logged in as...
    •   Error is false or true?
    •   Where’s the error?
{ "#error": false, "#data": { "#error": true, "#message": "Wrong
username or password." } }

{ "#error": false, "#data": { "sessid":
"02fd1c8a9d37ed9709ba154320340e8a", "user": { "uid": "1", ...




                     Drupalcamp Bucharest 2011
DRUPALCL
client = new JSONServerClient(this,
  getString(R.string.sharedpreferences_name),
  getString(R.string.SERVER), getString(R.string.API_KEY),
  getString(R.string.DOMAIN), getString(R.string.ALGORITHM),
  Long.parseLong(getString(R.string.SESSION_LIFETIME)));


<string name="app_name">AndroidDemo</string>
<string name="sharedpreferences_name">AndroidDemoPrefs</string>
<string name="SERVER">http://0001.ro/alex/drupalcamp/services/
services/json</string>
<string name="API_KEY">85255b11393bc0ee19d29758a043a698</string>
<string name="DOMAIN">http://mobile.0001.ro</string>
<string name="ALGORITHM">HmacSHA256</string>
<string name="SESSION.LIFETIME">1209600</string>



                     Drupalcamp Bucharest 2011
DRUPALCL
•   Has some methods built in
•   Just parse the response
•   For other methods do client.call()




             Drupalcamp Bucharest 2011
DRUPALCL
String result = client.userLogin(userText.getText().toString(),
passText.getText().toString());

JSONObject r = new JSONObject(result).getJSONObject("#data");
boolean error;
try {
  error = d.getBoolean("#error");
}
catch (Exception e) {
  error = false;
}

if (!error) {
  String session = d.getString("sessid");
  client.setSessionId(session);
}
else {
  finish();
}

                       Drupalcamp Bucharest 2011
DRUPALCL
try {
  JSONObject node = new JSONObject();
  node.put("type", "story");
  node.put("title", title.getText().toString());
  node.put("body", body.getText().toString());

  BasicNameValuePair[] params = new BasicNameValuePair[1];
  params[0] = new BasicNameValuePair("node", node.toString());

  String result = client.call("node.save", params);
 }
 catch (Exception e) {
   Log.v("drupalapp", e.toString());
   e.printStackTrace();
 }




                        Drupalcamp Bucharest 2011
RESOURCE
•   https://github.com/skyred/
    DrupalCloud
•   https://github.com/workhabitinc/
    drupal-ios-sdk
•   http://commons.apache.org/codec/
•   http://drupal.org/project/services
•   http://drupal.org/project/
            Drupalcamp Bucharest 2011
THANK
   andu@ctrlz.ro
   http://ctrlz.ro




Drupalcamp Bucharest 2011

More Related Content

What's hot

Introduction to CQ5
Introduction to CQ5Introduction to CQ5
Introduction to CQ5
Michele Mostarda
 
JS-IL: Getting MEAN in 1 Hour
JS-IL: Getting MEAN in 1 HourJS-IL: Getting MEAN in 1 Hour
JS-IL: Getting MEAN in 1 Hour
Valeri Karpov
 
Catch 22: FLex APps
Catch 22: FLex APpsCatch 22: FLex APps
Catch 22: FLex APpsYash Mody
 
DotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactDotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + react
Chen-Tien Tsai
 
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Corey Clark, Ph.D.
 
Bringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkers
Corey Clark, Ph.D.
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
Valeri Karpov
 
API Design & Security in django
API Design & Security in djangoAPI Design & Security in django
API Design & Security in django
Tareque Hossain
 
Node and Azure
Node and AzureNode and Azure
Node and Azure
Jason Gerard
 
Offline first, the painless way
Offline first, the painless wayOffline first, the painless way
Offline first, the painless way
Marcel Kalveram
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
drupalcampest
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopValeri Karpov
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
Irfan Maulana
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webmin
postrational
 
Herding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandboxHerding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandbox
ColdFusionConference
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
Irfan Maulana
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
PHP Indonesia
 
Server Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.jsServer Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.js
Jeff Geerling
 
Bringing Interactivity to Your Drupal Site with Node.js Integration
Bringing Interactivity to Your Drupal Site with Node.js IntegrationBringing Interactivity to Your Drupal Site with Node.js Integration
Bringing Interactivity to Your Drupal Site with Node.js Integration
Acquia
 

What's hot (20)

Demystifying HTML5
Demystifying HTML5Demystifying HTML5
Demystifying HTML5
 
Introduction to CQ5
Introduction to CQ5Introduction to CQ5
Introduction to CQ5
 
JS-IL: Getting MEAN in 1 Hour
JS-IL: Getting MEAN in 1 HourJS-IL: Getting MEAN in 1 Hour
JS-IL: Getting MEAN in 1 Hour
 
Catch 22: FLex APps
Catch 22: FLex APpsCatch 22: FLex APps
Catch 22: FLex APps
 
DotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactDotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + react
 
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
 
Bringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkers
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
 
API Design & Security in django
API Design & Security in djangoAPI Design & Security in django
API Design & Security in django
 
Node and Azure
Node and AzureNode and Azure
Node and Azure
 
Offline first, the painless way
Offline first, the painless wayOffline first, the painless way
Offline first, the painless way
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webmin
 
Herding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandboxHerding cats managing ColdFusion servers with commandbox
Herding cats managing ColdFusion servers with commandbox
 
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
 
Server Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.jsServer Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.js
 
Bringing Interactivity to Your Drupal Site with Node.js Integration
Bringing Interactivity to Your Drupal Site with Node.js IntegrationBringing Interactivity to Your Drupal Site with Node.js Integration
Bringing Interactivity to Your Drupal Site with Node.js Integration
 

Viewers also liked

Critical Chain
Critical ChainCritical Chain
Critical Chain
Uwe Techt
 
GDD HTML5, Flash, and the Battle for Faster Cat Videos
GDD HTML5, Flash, and the Battle for Faster Cat VideosGDD HTML5, Flash, and the Battle for Faster Cat Videos
GDD HTML5, Flash, and the Battle for Faster Cat Videos
Greg Schechter
 
#perfmatters - Optimizing the Critical Rendering Path
#perfmatters - Optimizing the Critical Rendering Path#perfmatters - Optimizing the Critical Rendering Path
#perfmatters - Optimizing the Critical Rendering Path
Johannes Weber
 
Ws critical chainproject_0408
Ws critical chainproject_0408Ws critical chainproject_0408
Ws critical chainproject_0408ICV
 
Elaboración Políticas Alternativas de Vivienda social
Elaboración Políticas Alternativas de Vivienda socialElaboración Políticas Alternativas de Vivienda social
Elaboración Políticas Alternativas de Vivienda social
ProGobernabilidad Perú
 
GTUG/GDDDE 2011 Android Tablet Use Cases
GTUG/GDDDE 2011 Android Tablet Use CasesGTUG/GDDDE 2011 Android Tablet Use Cases
GTUG/GDDDE 2011 Android Tablet Use Cases
ndomrose
 
Disciplinaries, grievances and settlement discussions
Disciplinaries, grievances and settlement discussionsDisciplinaries, grievances and settlement discussions
Disciplinaries, grievances and settlement discussions
Backhouse Solicitors
 
Supply Chain Visibility - das uneingelöste Versprechen?
Supply Chain Visibility - das uneingelöste Versprechen?Supply Chain Visibility - das uneingelöste Versprechen?
Supply Chain Visibility - das uneingelöste Versprechen?
Daniel Terner
 
Agile Methoden und die Theory of Constraints
Agile Methoden und die Theory of ConstraintsAgile Methoden und die Theory of Constraints
Agile Methoden und die Theory of Constraints
Frank Lange
 
TOC in der Beratungspraxis 21.08.15
TOC in der Beratungspraxis 21.08.15TOC in der Beratungspraxis 21.08.15
TOC in der Beratungspraxis 21.08.15
ICV
 

Viewers also liked (10)

Critical Chain
Critical ChainCritical Chain
Critical Chain
 
GDD HTML5, Flash, and the Battle for Faster Cat Videos
GDD HTML5, Flash, and the Battle for Faster Cat VideosGDD HTML5, Flash, and the Battle for Faster Cat Videos
GDD HTML5, Flash, and the Battle for Faster Cat Videos
 
#perfmatters - Optimizing the Critical Rendering Path
#perfmatters - Optimizing the Critical Rendering Path#perfmatters - Optimizing the Critical Rendering Path
#perfmatters - Optimizing the Critical Rendering Path
 
Ws critical chainproject_0408
Ws critical chainproject_0408Ws critical chainproject_0408
Ws critical chainproject_0408
 
Elaboración Políticas Alternativas de Vivienda social
Elaboración Políticas Alternativas de Vivienda socialElaboración Políticas Alternativas de Vivienda social
Elaboración Políticas Alternativas de Vivienda social
 
GTUG/GDDDE 2011 Android Tablet Use Cases
GTUG/GDDDE 2011 Android Tablet Use CasesGTUG/GDDDE 2011 Android Tablet Use Cases
GTUG/GDDDE 2011 Android Tablet Use Cases
 
Disciplinaries, grievances and settlement discussions
Disciplinaries, grievances and settlement discussionsDisciplinaries, grievances and settlement discussions
Disciplinaries, grievances and settlement discussions
 
Supply Chain Visibility - das uneingelöste Versprechen?
Supply Chain Visibility - das uneingelöste Versprechen?Supply Chain Visibility - das uneingelöste Versprechen?
Supply Chain Visibility - das uneingelöste Versprechen?
 
Agile Methoden und die Theory of Constraints
Agile Methoden und die Theory of ConstraintsAgile Methoden und die Theory of Constraints
Agile Methoden und die Theory of Constraints
 
TOC in der Beratungspraxis 21.08.15
TOC in der Beratungspraxis 21.08.15TOC in der Beratungspraxis 21.08.15
TOC in der Beratungspraxis 21.08.15
 

Similar to Drupal, Android and iPhone

Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
Alex S
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
Marko Heijnen
 
iOS & Drupal
iOS & DrupaliOS & Drupal
iOS & Drupal
Foti Dim
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
Lorna Mitchell
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
Ortus Solutions, Corp
 
Developing Azure Functions as custom connectors for Flow and Nintex
Developing Azure Functions as custom connectors for Flow and NintexDeveloping Azure Functions as custom connectors for Flow and Nintex
Developing Azure Functions as custom connectors for Flow and Nintex
DocFluix, LLC
 
Made for Mobile - Let Office 365 Power Your Mobile Apps
Made for Mobile - Let Office 365 Power Your Mobile AppsMade for Mobile - Let Office 365 Power Your Mobile Apps
Made for Mobile - Let Office 365 Power Your Mobile Apps
SPC Adriatics
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
Lorna Mitchell
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.js
Richard Rodger
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
Alexandru Badiu
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
European Collaboration Summit
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
Lorna Mitchell
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018
DocFluix, LLC
 
Apigility-powered API's on IBM i
Apigility-powered API's on IBM iApigility-powered API's on IBM i
Apigility-powered API's on IBM i
chukShirley
 

Similar to Drupal, Android and iPhone (20)

Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 
iOS & Drupal
iOS & DrupaliOS & Drupal
iOS & Drupal
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
Developing Azure Functions as custom connectors for Flow and Nintex
Developing Azure Functions as custom connectors for Flow and NintexDeveloping Azure Functions as custom connectors for Flow and Nintex
Developing Azure Functions as custom connectors for Flow and Nintex
 
Made for Mobile - Let Office 365 Power Your Mobile Apps
Made for Mobile - Let Office 365 Power Your Mobile AppsMade for Mobile - Let Office 365 Power Your Mobile Apps
Made for Mobile - Let Office 365 Power Your Mobile Apps
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.js
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublin
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018
 
Apigility-powered API's on IBM i
Apigility-powered API's on IBM iApigility-powered API's on IBM i
Apigility-powered API's on IBM i
 

More from Alexandru Badiu

Behavior Driven Development with Drupal
Behavior Driven Development with DrupalBehavior Driven Development with Drupal
Behavior Driven Development with Drupal
Alexandru Badiu
 
Drupal 8
Drupal 8Drupal 8
Drupal 8
Alexandru Badiu
 
Drupal as a first class mobile platform
Drupal as a first class mobile platformDrupal as a first class mobile platform
Drupal as a first class mobile platform
Alexandru Badiu
 
Cloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloudCloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloud
Alexandru Badiu
 
REST Drupal
REST DrupalREST Drupal
REST Drupal
Alexandru Badiu
 
Cloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloudCloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloud
Alexandru Badiu
 
Using Features
Using FeaturesUsing Features
Using Features
Alexandru Badiu
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
Alexandru Badiu
 
Publish and Subscribe
Publish and SubscribePublish and Subscribe
Publish and Subscribe
Alexandru Badiu
 
Using Features
Using FeaturesUsing Features
Using Features
Alexandru Badiu
 
Concepte de programare functionala in Javascript
Concepte de programare functionala in JavascriptConcepte de programare functionala in Javascript
Concepte de programare functionala in Javascript
Alexandru Badiu
 
Drupal and Solr
Drupal and SolrDrupal and Solr
Drupal and Solr
Alexandru Badiu
 
Prezentare Wurbe
Prezentare WurbePrezentare Wurbe
Prezentare Wurbe
Alexandru Badiu
 

More from Alexandru Badiu (13)

Behavior Driven Development with Drupal
Behavior Driven Development with DrupalBehavior Driven Development with Drupal
Behavior Driven Development with Drupal
 
Drupal 8
Drupal 8Drupal 8
Drupal 8
 
Drupal as a first class mobile platform
Drupal as a first class mobile platformDrupal as a first class mobile platform
Drupal as a first class mobile platform
 
Cloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloudCloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloud
 
REST Drupal
REST DrupalREST Drupal
REST Drupal
 
Cloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloudCloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloud
 
Using Features
Using FeaturesUsing Features
Using Features
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Publish and Subscribe
Publish and SubscribePublish and Subscribe
Publish and Subscribe
 
Using Features
Using FeaturesUsing Features
Using Features
 
Concepte de programare functionala in Javascript
Concepte de programare functionala in JavascriptConcepte de programare functionala in Javascript
Concepte de programare functionala in Javascript
 
Drupal and Solr
Drupal and SolrDrupal and Solr
Drupal and Solr
 
Prezentare Wurbe
Prezentare WurbePrezentare Wurbe
Prezentare Wurbe
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 

Drupal, Android and iPhone

  • 1. DRUPAL, ANDROID AND IPHONE Badiu Alexandru Fratu Mihai Drupalcamp Bucharest 2011
  • 2. ABOUT US • We work at Adulmec • We do fine products such as Dealfever, Urbo and Adulmec • We sometime build mobile apps • Ataxi, Urbo, games and soon the Adulmec app Drupalcamp Bucharest 2011
  • 3. CONNECTI • You expose some functionality as REST or some sort of web service • Your mobile application makes HTTP calls • Authentication? Access control? Drupalcamp Bucharest 2011
  • 4. CONNECTI • Two ways • Use the Services module • Use a custom solution • Depends on your requirements Drupalcamp Bucharest 2011
  • 5. FOR • Adulmec Coupon Redeem - custom • Urbo - Services Drupalcamp Bucharest 2011
  • 6. CUSTOM • Write php pages • Without Drupal • Lightweight Drupal • Full Drupal • Output XML or JSON • Make HTTP call and parse result Drupalcamp Bucharest 2011
  • 7. CUSTOM • Latest news app • Shows a list of the latest posts on a site • Click on a post, go to the site Drupalcamp Bucharest 2011
  • 8. <?php CUSTOM chdir('../'); require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $response = array(); $result = db_query_range('SELECT nid, title FROM {node} WHERE type="story" ORDER BY created DESC', 0, 10); while ($row = db_fetch_object($result)) { $response[] = array('title' => $row->title, 'url' => 'node/' . $row->nid); } drupal_json($response); Drupalcamp Bucharest 2011
  • 10. CUSTOM URI uri = new URI("http://0001.ro/alex/drupalcamp/services/pages/list.php"); HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(uri); HttpResponse response = client.execute(request); InputStream is = response.getEntity().getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String result = br.readLine(); adapter.clear(); JSONArray r = new JSONArray(result); for (int i = 0; i < r.length(); i++) { JSONObject jitem = r.getJSONObject(i); SubtitleItem item = new SubtitleItem(jitem.getString("title"), jitem.getString("url")); adapter.add(item); } adapter.notifyDataSetChanged(); Drupalcamp Bucharest 2011
  • 11. SERVICES • Creates web services out of Drupal functions • Concepts: service and server • Autenthication plugins • Pluggable Drupalcamp Bucharest 2011
  • 12. SERVICES • Out of the box: Comments, Files, Menu, Node, Search, System, Taxonomy, User, Views • XMLRPC Server • Key based authentication Drupalcamp Bucharest 2011
  • 13. SERVICES • We use XMLRPC in iOS apps • We use JSON in Android apps • json_server • Demo with standard json parser • GSON and Jackson • Streaming and mapping Drupalcamp Bucharest 2011
  • 14. SERVICES • Drupalcloud for Android • Custom code for iOS • drupal-ios-sdk Drupalcamp Bucharest 2011
  • 15. SERVICES • Key auth allows you to grant access just to some specific apps • Fine-grained: user authentication • Session id is used in every call • system.connect Drupalcamp Bucharest 2011
  • 16. SERVICES • hash - sha of domain, time and nonce • domain • timestamp • nonce • session Drupalcamp Bucharest 2011
  • 17. SERVICES • call system.connect - get session • use session in every call • call user.login - get new session • use new session in every call • call user.logout • call system.connect - get session • repeat Drupalcamp Bucharest 2011
  • 18. SERVICES • What about saving session across app launches? • Save session and timestamp to prefs after login or connect • At launch check that the saved session has not expired • If not, use that session • Otherwise system.connect Drupalcamp Bucharest 2011
  • 19. WTFS • userLogin returns new session • no user uid • no way to set it in the client • we create our own • json_server does not work Drupalcamp Bucharest 2011
  • 20. public void setSessionId(String sessionId) { SharedPreferences auth = mCtx.getSharedPreferences(mPREFS_AUTH, 0); SharedPreferences.Editor editor = auth.edit(); editor.putString("sessionid", sessionId); editor.putLong("sessionid_timestamp", new Date().getTime() / 100); editor.commit(); } Drupalcamp Bucharest 2011
  • 21. WTFS • Services is inconsistent or weird • You’re already logged in as... • Error is false or true? • Where’s the error? { "#error": false, "#data": { "#error": true, "#message": "Wrong username or password." } } { "#error": false, "#data": { "sessid": "02fd1c8a9d37ed9709ba154320340e8a", "user": { "uid": "1", ... Drupalcamp Bucharest 2011
  • 22. DRUPALCL client = new JSONServerClient(this, getString(R.string.sharedpreferences_name), getString(R.string.SERVER), getString(R.string.API_KEY), getString(R.string.DOMAIN), getString(R.string.ALGORITHM), Long.parseLong(getString(R.string.SESSION_LIFETIME))); <string name="app_name">AndroidDemo</string> <string name="sharedpreferences_name">AndroidDemoPrefs</string> <string name="SERVER">http://0001.ro/alex/drupalcamp/services/ services/json</string> <string name="API_KEY">85255b11393bc0ee19d29758a043a698</string> <string name="DOMAIN">http://mobile.0001.ro</string> <string name="ALGORITHM">HmacSHA256</string> <string name="SESSION.LIFETIME">1209600</string> Drupalcamp Bucharest 2011
  • 23. DRUPALCL • Has some methods built in • Just parse the response • For other methods do client.call() Drupalcamp Bucharest 2011
  • 24. DRUPALCL String result = client.userLogin(userText.getText().toString(), passText.getText().toString()); JSONObject r = new JSONObject(result).getJSONObject("#data"); boolean error; try { error = d.getBoolean("#error"); } catch (Exception e) { error = false; } if (!error) { String session = d.getString("sessid"); client.setSessionId(session); } else { finish(); } Drupalcamp Bucharest 2011
  • 25. DRUPALCL try { JSONObject node = new JSONObject(); node.put("type", "story"); node.put("title", title.getText().toString()); node.put("body", body.getText().toString()); BasicNameValuePair[] params = new BasicNameValuePair[1]; params[0] = new BasicNameValuePair("node", node.toString()); String result = client.call("node.save", params); } catch (Exception e) { Log.v("drupalapp", e.toString()); e.printStackTrace(); } Drupalcamp Bucharest 2011
  • 26. RESOURCE • https://github.com/skyred/ DrupalCloud • https://github.com/workhabitinc/ drupal-ios-sdk • http://commons.apache.org/codec/ • http://drupal.org/project/services • http://drupal.org/project/ Drupalcamp Bucharest 2011
  • 27. THANK andu@ctrlz.ro http://ctrlz.ro Drupalcamp Bucharest 2011

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n