StackMob & Appcelerator Module Part One

1,416 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,416
On SlideShare
0
From Embeds
0
Number of Embeds
75
Actions
Shares
0
Downloads
24
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

StackMob & Appcelerator Module Part One

  1. 1. ANDThis is an introductory post on using StackMob for the backend services of your mobileapplications. The StackMob platform helps you build, deploy and scale your backendwhile making it very easy for you to add push notifications, social integration and moreto your apps. Here is a blog posting on why services like StackMob are a value-add forAppcelerator developers.Why a PaaS for Mobile Developers Makes SenseHere is my brief outline on the benefits StackMob provides: More Information Availableon website • REST Based API • Custom Code Integration • Social Media Integration • Push Notification • Separation of Production and Staging EnvironmentsIn this first part of a three part series we will cover a very basic implementation using aJavascript REST based API. StackMob provides an IOS and Android SDK so you can createa native module if you like. In the last few weeks I created a functioning IOS module andhave started working on an Android module that I will release to the Marketplace soon.In this initial example I have created, there are two simple objects: users and photos. Wewill expand on the relationship in a later posting, but this is good enough for now.First you need to go to StackMob and get an account. They are still in beta, but if youindicate that you are trying to integrate with Appcelerator, they will give you priorityaccess.Create An App
  2. 2. Here we will create our user object. StackMob allows us to specify that the object is auser object and this is how we can log in and out of our application. No trying to rollyour own authentication method. It is using xAuth over HTTPS, so you are all set.Click "Create a Schema" to Add the User Object
  3. 3. then enter the appropriate information for your user object
  4. 4. I have added another object called Photos. I am using it to post data to the server.StackMob made the integration with Amazon S3 very easy.Here is my photo object
  5. 5. When you are all done, you should have something that looks similar to this, if you havebeen following along.
  6. 6. In a few minutes, I created my app and created two objects using their platform. Letstest out what we created in the Console before we even get to code; click on the linkthat says "Console"This will bring you to the Console that will allow you to go through all ofthe CRUDmethods to test your objects you have created
  7. 7. If you click GET for the default method our application, you will get a listing of theschema you have created based on your application object; the output should looksimilar to this.Ok enough StackMob, where is the Appcelerator code....First you need to initialize the module. I have created a file called credentials whichholds your StackMob credentials and associated application information. Here is whatthe file looks like.Now with the credentials set, here is how you intialize the module.And finally, here is how you create a user object to go along with the object you createdin the console.the successful output from the module should look something like this.The client create method is a nice wrapper around a POST of the REST API call to createthe user object. The whole objective of the module I created is to cut down on the timespent coding the oAuth API and get straight to doing productive things. The way themodule is created, it will take the parameters and return the results as a JSON objectHere we make an API call through the module to get the list of all of the user(s) we havecreated in the system.
  8. 8. And to get a specific user, we can pass in the value for the user name in the GET querylike this.In Part Two I will cover setting up the Amazon S3 Integration and the uploading of imagefiles to the system.Complete ListingLINKS • StackMob • Appcelerator • Zipped Project Used in the blog posting • Part 1a - Logging In with StackMob User Accounts  

×