Vector Search -An Introduction in Oracle Database 23ai.pptx
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