SlideShare uma empresa Scribd logo
1 de 27
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 specic 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

Mais conteĂşdo relacionado

Mais procurados

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 HourValeri 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 + reactChen-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 WebWorkersCorey 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 MongoDBValeri Karpov
 
API Design & Security in django
API Design & Security in djangoAPI Design & Security in django
API Design & Security in djangoTareque Hossain
 
Node and Azure
Node and AzureNode and Azure
Node and AzureJason Gerard
 
Offline first, the painless way
Offline first, the painless wayOffline first, the painless way
Offline first, the painless wayMarcel 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 DevelopmentIrfan 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 Webminpostrational
 
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 commandboxColdFusionConference
 
[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 JavascriptIrfan Maulana
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of dockerPHP 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.jsJeff 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 IntegrationAcquia
 

Mais procurados (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
 

Destaque

Critical Chain
Critical ChainCritical Chain
Critical ChainUwe 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 VideosGreg Schechter
 
#perfmatters - Optimizing the Critical Rendering Path
#perfmatters - Optimizing the Critical Rendering Path#perfmatters - Optimizing the Critical Rendering Path
#perfmatters - Optimizing the Critical Rendering PathJohannes 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 socialProGobernabilidad 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 Casesndomrose
 
Disciplinaries, grievances and settlement discussions
Disciplinaries, grievances and settlement discussionsDisciplinaries, grievances and settlement discussions
Disciplinaries, grievances and settlement discussionsBackhouse 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 ConstraintsFrank 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.15ICV
 

Destaque (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
 

Semelhante a Drupal, Android and iPhone

Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGapAlex S
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 
iOS & Drupal
iOS & DrupaliOS & Drupal
iOS & DrupalFoti Dim
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
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 NintexDocFluix, 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 AppsSPC Adriatics
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services TutorialLorna 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.jsRichard Rodger
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublinRichard 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 APIAlexandru Badiu
 
[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 FunctionsEuropean Collaboration Summit
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorialLorna 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 PlatformAntonio 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 2018DocFluix, 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 ichukShirley
 

Semelhante a 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
 

Mais de Alexandru Badiu

Behavior Driven Development with Drupal
Behavior Driven Development with DrupalBehavior Driven Development with Drupal
Behavior Driven Development with DrupalAlexandru 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 platformAlexandru 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 cloudAlexandru 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 cloudAlexandru 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 SubscribeAlexandru Badiu
 
Concepte de programare functionala in Javascript
Concepte de programare functionala in JavascriptConcepte de programare functionala in Javascript
Concepte de programare functionala in JavascriptAlexandru Badiu
 

Mais de 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
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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 ne 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 specic 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

Notas do Editor

  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