Skip to content

Instantly share code, notes, and snippets.

@SidneyAllen
Forked from aaronksaunders/app.js
Created October 15, 2012 17:43
Show Gist options
  • Save SidneyAllen/3893922 to your computer and use it in GitHub Desktop.
Save SidneyAllen/3893922 to your computer and use it in GitHub Desktop.
complete stackmob appcelerator example
//
// app.js
//
// aaron@clearlyinnovative.com
// blog.clearlyinnovative.com
//
// @see http://stackmob.com
//
//
//include StackMob & credentials module
var credentials = require('credentials').C;
var stackmob = require('stackmob-module.min');
//create StackMob Client
var client = new stackmob.Client(credentials.STACKMOB_APP_NAME,
credentials.STACKMOB_PUBLIC_KEY,
credentials.STACKMOB_PRIVATE_KEY,
credentials.STACKMOB_USER_OBJECT_NAME);
// this will dump out the objects I have created for this sample
client.get({
className : 'listapi',
success : function(data) {
Ti.API.info('listapi ' + JSON.stringify(JSON.parse(data.text)));
}
});
// ===============================================================
//
// Create a User
//
// ===============================================================
client.create({
className : 'user',
params : {
"username" : 'aaron-' + Ti.Platform.createUUID(),
"password" : "password"
},
success : function(data) {
Ti.API.info("create user " + JSON.stringify(JSON.parse(data.text)));
doUserCreatedSuccess(data);
},
});
// ===============================================================
//
// Get all User(s)
//
// ===============================================================
client.get({
className : 'user',
success : function(data) {
Ti.API.info("list user(s) " + JSON.stringify(JSON.parse(data.text)));
}
});
// ===============================================================
//
// Get a specific user
//
// ===============================================================
client.get({
className : 'user',
params : {
'username' : "REPLACE WITH VALID USERNAME",
},
success : function(data) {
Ti.API.info("list user: " + JSON.stringify(JSON.parse(data.text)));
},
error : function(data) {
var response = JSON.stringify(data);
Ti.API.error(String.format('fail: %s - %s', 'get user', response));
}
});
//
// credentials.js
//
// aaron@clearlyinnovative.com
// blog.clearlyinnovative.com
//
// @see http://stackmob.com
//
exports.C = {
STACKMOB_PUBLIC_KEY : 'replace this with your public', //replace this with your public
STACKMOB_PRIVATE_KEY : 'replace this with your public', //replace this with your public
STACKMOB_APP_NAME : 'people_interact',
STACKMOB_USER_OBJECT_NAME : 'user'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment