문제

My code below will not pull the user.username from the log in. I tried the Facebook sdk hello Facebook too and it still doesn't grab the user.username. The strange part is that it used to at one point. Part of my code is below. Please advise.

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                            user:(id<FBGraphUser>)user {
    // here we use helper properties of FBGraphUser to dot-through to first_name and
    // id properties of the json response from the server; alternatively we could use
    // NSDictionary methods such as objectForKey to get values from the my json object
    self.labelFirstName.text = [NSString stringWithFormat:@"Hello %@!", user.first_name];
    // setting the profileID property of the FBProfilePictureView instance
    // causes the control to fetch and display the profile picture for the user
    self.profilePic.profileID = user.id;
    self.loggedInUser = user;
    FitGoalAppDelegate *appDelegate = (FitGoalAppDelegate *)[[UIApplication sharedApplication] delegate];
    appDelegate.uname = nil;
    appDelegate.uname = user;
    appDelegate.lastname = user.last_name;
    appDelegate.firstname = user.first_name;
    NSLog(@"First Name=%@",appDelegate.firstname);
    NSLog(@"Last Name=%@",appDelegate.lastname);
    NSLog(@"Real Userbame %@",user.username);
    NSLog(@"Copied Userbame %@",appDelegate.uname.username);
}
도움이 되었습니까?

해결책

Username is not available in Facebook API v2.0

다른 팁

but there's a trick you can use. After receiving the id you can make a call like this https://graph.facebook.com/{user_id} you will get the metadata of the user containing username.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top