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

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

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

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

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