用户在其iOS应用程序中登录时访问基本配置文件

时间:2013-04-23 10:19:35

标签: ios objective-c facebook facebook-login

我已经使用Facebook图形api进行facebook身份验证或者获取用户Facebook详细信息但是我还希望实现一个更多的东西..假设用户已经通过Facebook iOS app在Facebook上登录当我打开我的应用程序或点击登录按钮然后它向我显示警告,其中“应用程序想要访问您的基本个人资料信息”,例如Friend Smasher应用程序,以便用户能够获得他的基本知识通过单击“确定”按钮进行配置文件,但如果用户未登录其Facebook iOS应用程序,则可能会要求输入用户名和密码或登录页面。

如果有人知道如何在应用中访问基本用户个人资料,如果用户已经在Facebook iOS应用中登录,那么请帮帮我。

1 个答案:

答案 0 :(得分:0)

鉴于您已经连接了用户,这就是您获取信息的方式。

FBRequest *userRequest = [FBRequest requestForGraphPath:@"/me/?fields=gender,interested_in,relationship_status,email,first_name,last_name,location,id,birthday"];

[userRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    if (!error) {
         //For instance:
         NSLog([result first_name]);
         NSLog([result last_name]);
         NSLog([result birthday]);
         NSLog([result first_name]);
         NSLog([[result objectForKey:(@"location")] objectForKey:(@"name")]);
    } else {
         NSLog(@"User not found");
    }
];