Skip to content

Instantly share code, notes, and snippets.

@marks

marks/app.js Secret

Created Jan 5, 2012
Embed
What would you like to do?
Ti.include("lib/cocoafish.js") // include CocoaFish module code
var config = require("config").CONFIG // include config.js dict as config variable
var CF = new Cocoafish(config.COCOAFISH_OAUTH_KEY,config.COCOAFISH_OAUTH_SECRET) // initiate Cocoafish variable
// following function called when they choose an image. i've tried a ton of variatiosn
function handleChosenImage(w,image){
// set imageView to the image
w.imageView.image = image;
// timestamp stuff
var timestamp = IQE_makeTimestamp()
// image stuff
var tempFile = Titanium.Filesystem.createTempFile();
tempFile.write(image);
var contents = tempFile.read();
// upload to cocoafish
CF.sendRequest('photos/create.json', 'POST', {photo: tempFile}, false, CFUploadImageCallback); // 400 - unable to load. i've tried tempFile, contents, tempFile.getNativePath() and a ton of other variations.
}
// following function is called when someone submits the form. and it works.
function handleLoginEvent(w) {
var username = w.usernameTextField.value;
var password = w.passwordTextField.value;
var login_data = {login : username, password : password }
if(username == null || username.length == 0 || password == null || password.length == 0) {
alert("Please enter a username (usually your email) and password to login")
return;
} else {
CF.sendRequest('users/login.json', 'POST', login_data, false, function(data){
if(data) {
if(data.meta) {
var meta = data.meta;
if(meta.status == 'ok' && meta.code == 200 && meta.method_name == 'loginUser') {
alert("login success")
CF.sendRequest('users/show/me.json', 'GET', null, false, aboutMeCallback)
} else {
alert("Login unsuccessful")
}
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.