Skip to content

Instantly share code, notes, and snippets.

@jamesbrink
Created March 11, 2011 01:42
Show Gist options
  • Save jamesbrink/865329 to your computer and use it in GitHub Desktop.
Save jamesbrink/865329 to your computer and use it in GitHub Desktop.
- (void)doLogin:(id)sender
{
var UserSession = {
"user_session" : {
"login" : [LoginUserName objectValue],
"password" : [LoginPassword objectValue],
"remember_me" : false
}
};
var request = [[CPURLRequest alloc] initWithURL:[CPURL URLWithString: @"/user_sessions"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setHTTPBody:[CPString JSONFromObject:UserSession]];
var response = CPHTTPURLResponse;
[CPURLConnection sendSynchronousRequest:request returningResponse:response];
alert(response.responseText());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment