Skip to content

Instantly share code, notes, and snippets.

@dbrajkovic
Created March 2, 2011 19:56
Show Gist options
  • Save dbrajkovic/851609 to your computer and use it in GitHub Desktop.
Save dbrajkovic/851609 to your computer and use it in GitHub Desktop.
+(void)updateAccount:(CPDictionary)accountParams delegate:(id)delegate
{
var urlString = [CPString stringWithFormat:@"http://api.webservice.com/account/update.json"];
var request = [self requestWithURLString:urlString];
var name = [accountParams valueForKey:@"name"];
var username = [accountParams valueForKey:@"username"];
var email = [accountParams valueForKey:@"email"];
var postBody = [CPString stringWithFormat:@"name=%@&username=%@&email=%@", name, username, email];
[request setValue:[postBody length] forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setValue:"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postBody];
[CPURLConnection connectionWithRequest:request delegate:delegate];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment