下面的代码不会从登录中提取user.username。我也试过Facebook sdk你好Facebook,它仍然没有抓住user.username。奇怪的是,它曾经在某个时刻使用过。我的部分代码如下。请指教。
- (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);
}
答案 0 :(得分:0)
Facebook API v2.0中没有用户名
答案 1 :(得分:0)
但是你可以使用一个技巧。收到ID后,您可以拨打此https://graph.facebook.com/ {user_id}之类的电话,您将获得包含用户名的用户的元数据。