Your SlideShare is downloading. ×
0
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

The Anatomy of Apps - How iPhone, Android & Facebook Apps Consume APIs

6,497

Published on

Building mobile apps is different from building web apps. Developers need to understand the unique demands that mobile apps place on APIs and considerations across different client and back-end …

Building mobile apps is different from building web apps. Developers need to understand the unique demands that mobile apps place on APIs and considerations across different client and back-end platforms. Mobile apps also introduce new issues for security and scalability.

WARNING: These slides contain lots of code.

We Will Discuss »


Why building mobile apps is different
A roundup of different client libraries and frameworks
Considerations for selecting mobile back-end platforms

Published in: Technology
1 Comment
8 Likes
Statistics
Notes
  • <br /><iframe width="350" height="288" src="http://www.youtube.com/embed/uI4d9DHMrvE" frameborder="0" allowfullscreen></iframe>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
6,497
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
120
Comments
1
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Creative Commons Attribution-Share Alike 3.0 United States License
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • Android &amp; iOS default response is a hash/dictionaryRuby on Rails
  • iOSFun factoid: the app store will reject your app if you don’t properly test your app using the reachability APIAndroidSearch around for Reachability - Connectivity Manager
  • If you provide and consume the api then auth is what u make it.Oauth 2 is a standard but not too heavyAbout 70% of the reason folks go to a special purpose built client library is auth, the second is object marshaling.The standard clients start to screw you over…Parameter signing are a nightmare for the app developer. RestKit
  • AndroidSUN JerseySpring MobileTradeoffs are around the App SizeForOauth: do the flow with the web browser but oauth 2 is a really pragmatic spec you can also pass a username and password. It will be up to the app. Client id and the client token. Get back an access token either in the header or as a param.
  • AndroidSUN JerseySpring MobileTradeoffs are around the App SizeForOauth: do the flow with the web browser but oauth 2 is a really pragmatic spec you can also pass a username and password. It will be up to the app. Client id and the client token. Get back an access token either in the header or as a param.
  • Transcript

    • 1. The Anatomy of AppsHow iPhone, Android & Facebook Apps Consume APIsEd Anuff@edanuffSam Ramji@sramjiBrian Mulloy@landlessness Apigee @apigee
    • 2. groups.google.com/group/api-craft
    • 3. youtube.com/apigee
    • 4. New! IRC Channel #api-craft
    • 5. App App App World of API Internal App APIUser Store Developer APIs Team Systems
    • 6. Dogs API/dogs/ownersAuthorizationOAuth 2.0RESTful API Design - Second Editionhttp://www.youtube.com/watch?v=QpAhXa12xvU
    • 7. Build an iPhone App, an Android App and aFacebook Web App**Ruby on Rails app hosted on Herokuhttp://devcenter.heroku.com/articles/facebook
    • 8. App App App World of API Internal App APIUser Store Developer APIs Team Systems
    • 9. Start with a basic HTTP request
    • 10. AndroidHttpClient client = new DefaultHttpClient();HttpGet httpGet = new HttpGet("http://api.apizoo.com/v1/dogs");HttpResponse response = client.execute(httpGet);iOSNSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.apizoo.com/v1/dogs"]];NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];Ruby on Railsrequire net/httpresponse = Net::HTTP.get(‘api.apizoo.com/v1’, ‘/dogs’)
    • 11. Parse the data
    • 12. AndroidJSONObject dogs = new JSONObject(response);iOSimport "JSONKit.h"NSDictionary *dogs = [response objectFromData];Ruby on Railsrequire yajlparser = Yajl::Parser.newdogs = parser.parse(response) # returns a hash
    • 13. Resource Object Mapping
    • 14. RouteMapUse
    • 15. Android Spring MobileRouterequestEntity = new HttpEntity<Object>(requestHeaders);ResponseEntity<Dog> responseEntity = restTemplate.exchange("http://api.apizoo.com/v1/dogs/15", HttpMethod.GET, requestEntity, Dog.class);
    • 16. Android Spring MobileMap// Handled with introspection
    • 17. Android Spring MobileUseDog dog = responseEntity.getBody()
    • 18. iOS RestKitRoute#import <RestKit/RestKit.h>RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://api.apizoo.com/v1"];RKDynamicRouter* router = [[RKDynamicRouter new] autorelease];manager.router = router;[router routeClass:[Dog class] toResourcePath:@"/dogs" forMethod:RKRequestMethodPOST];[router routeClass:[Dog class] toResourcePath:@"/dogs/(dogID)"];
    • 19. iOS RestKitMap@implementation Dog+ (NSDictionary*)elementToPropertyMappings { return [NSDictionary dictionaryWithKeysAndObjects: @"name", @"color", nil];}@end
    • 20. iOS RestKitUseDog* dog = [Dog object];dog.name = @"Rover";Dog.color = @"red";[[RKObjectManager sharedManager] postObject:dog delegate:self];[[RKObjectManager sharedManager] deleteObject:dog delegate:self];
    • 21. Ruby on Rails ActiveResourceRouteresource :dogs
    • 22. Ruby on Rails ActiveResourceMapclass Dog < ActiveResource::Base self.site = "http://api.apizoo.com/v1"end
    • 23. Ruby on Rails ActiveResourceUsedog = Dog.new name: ‘Rover’, color: ‘red’dog.savedog.destroy
    • 24. Cache the response in a database
    • 25. Android Jersey + JacksonUsageRoll your own
    • 26. iOS RestKit + Core DataUsage#import <RestKit/CoreData/CoreData.h>RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://api.apizoo.com/v1"];manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"DogApp.sqlite"];@implementation Dog + (NSString*)primaryKeyProperty { return @"dogID"; }@end
    • 27. Ruby on Rails ActiveResource + ActiveRecordUsageclass DogResource < ActiveResource::Base self.site = http://api.apizoo.com/v1endclass Dog < ActiveRecord::Base # the before methods call DogResource methods before_create :create_resource before_update :update_resource before_destroy :destroy_resourceend
    • 28. Simple to do list
    • 29. Problem: we want new capabilities in our app notsupported by APIs.
    • 30. Usergrid - Data & Querieshttp://www.youtube.com/watch?v=zLl56sU5Bt0
    • 31. Androidusergrid_ sdkiOSUse RESTKitRuby on RailsProbably not applicable
    • 32. What about offline cases
    • 33. AndroidRoll your owniOS-(BOOL)reachable {Reachability *r = [Reachability reachabilityWithHostName:@"api.apizoo.com/v1"];NetworkStatus internetStatus = [r currentReachabilityStatus];if(internetStatus == NotReachable) { return NO;}return YES;}Ruby on RailsProbably not applicable
    • 34. Get authorization out of the wayAssumption: the APIs we consume use OAuth 2
    • 35. AndroidRoll your own
    • 36. iOS RestKitRKObjectManager* objectManager = [RKObjectManager sharedManager];objectManager.client.baseURL = @”api.apizoo.com/v1";objectManager.client.OAuth2AccessToken = @"YOUR ACCESS TOKEN";objectManager.client.authenticationType = RKRequestAuthenticationTypeOAuth2;
    • 37. Ruby on Rails Oauth Gem@consumer=OAuth::Consumer.new("key","secret", site: "api.apizoo.com/v1")@request_token=@consumer.get_request_tokensession[:request_token]=@request_tokenredirect_to @request_token.authorize_url@access_token=@request_token.get_access_token
    • 38. AndroidBuilt-in JSON, etc.Spring Mobile (bundles Jersey & Jackson)iOSJSONKitRestKitCore DataRuby on RailsYAJLActiveResourceOauth
    • 39. Coming Up: March Miniseries on Apps & APIs
    • 40. Questions?
    • 41. THANK YOUSubscribe to API webinars at:youtube.com/apigee
    • 42. THANK YOUChat on IRC#api-craft
    • 43. THANK YOUQuestions and ideas to:groups.google.com/group/api-craft
    • 44. THANK YOUContact us at:@edanuffed@apigee.com@sramjisramji@apigee.com@landlessnessbrian@apigee.com

    ×