I wrote the following code:
NSURL *url = [NSURL URLWithString:@\"http://api.twitter.com/1.1/users/show.json\"];
NSDictionary *params = [NSDictionary diction
this is what i have tried in past
[PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) {
if (!user) {
NSLog(@"Uh oh. The user cancelled the Twitter login.");
[[NSNotificationCenter defaultCenter] postNotificationName:notificationUserLoginFailed
object:error];
return;
} else {
// TODO find a way to fetch details with Twitter..
NSString * requestString = [NSString stringWithFormat:@"https://api.twitter.com/1.1/users/show.json?screen_name=%@", user.username];
NSURL *verify = [NSURL URLWithString:requestString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:verify];
[[PFTwitterUtils twitter] signRequest:request];
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if ( error == nil){
NSDictionary* result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
_NSLog(@"%@",result);
[user setObject:[result objectForKey:@"profile_image_url_https"]
forKey:@"picture"];
// does this thign help?
[user setUsername:[result objectForKey:@"screen_name"]];
NSString * names = [result objectForKey:@"name"];
NSMutableArray * array = [NSMutableArray arrayWithArray:[names componentsSeparatedByString:@" "]];
if ( array.count > 1){
[user setObject:[array lastObject]
forKey:@"last_name"];
[array removeLastObject];
[user setObject:[array componentsJoinedByString:@" " ]
forKey:@"first_name"];
}
[user saveInBackground];
}
[[NSNotificationCenter defaultCenter] postNotificationName:notificationUserDidLogin
object:nil];
return;
}
}];