Created
November 28, 2011 19:18
-
-
Save aaronksaunders/1401612 to your computer and use it in GitHub Desktop.
complete stackmob appcelerator example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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)); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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