Skip to content

Instantly share code, notes, and snippets.

@jlee42
Created December 6, 2012 19:07
Show Gist options
  • Save jlee42/4227255 to your computer and use it in GitHub Desktop.
Save jlee42/4227255 to your computer and use it in GitHub Desktop.
NSString *deviceUUID = [[NSUserDefaults standardUserDefaults] valueForKey:UUID_USER_DEFAULTS_KEY];
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
usernameField.text, @"user[pawsid]",
passwordField.text, @"user[password]",
deviceUUID, @"user[device_uuid]", nil];
NSString *urlString = [NSString stringWithFormat:@"%@://%@:%@/api/v2/json/api_users/sign_in",
[NSObject TT_PROTOCOL], [NSObject TT_HOST], [NSObject TT_PORT]];
AFHTTPClient *httpClient = [RKObjectManager sharedManager].HTTPClient;
NSURLRequest *request = [httpClient requestWithMethod:@"POST" path:urlString parameters:params];
RKHTTPRequestOperation *operation = [[RKHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(RKHTTPRequestOperation *operation, id responseObject) {
NSLog(@"success: %@", operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", operation.responseString);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment