我有一個按鈕,我想連接到Facebook,因爲我點擊它,我想要我所有的朋友在我的臉書。如何在iOS中的FACEBOOK SDK中從Facebook獲取朋友列表?
我可以訪問Facebook,並獲得Facebook令牌並將其保存在數據庫中。
我使用控制器A中的以下代碼連接到Facebook,但在CONTROLLER B中,我想要獲取好友列表。
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSString *fbAccessToken = [FBSession activeSession].accessTokenData.accessToken;
NSLog(@"Token is %@", fbAccessToken);
DataManager *dataManager = [[DataManager alloc] init];
/*flag is for identification, that from which account user has logged in, either facebook or
from account which he made using this app.
flag = facebook //if user is signed in using his facebook account
flag = myuser //if user is signed in using his own app account
*/
[dataManager saveloginData:fbAccessToken username:@"NO DATA" password:@"NO DATA" flag:@"facebook"];
// NSLog(@"Veer Suthar %@",user);
status = YES;
[self loginWithFacebookDirectly];
// 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:@" %@", 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;
NSLog(@"USER IS %@", user);
// self.loggedInUser = user;
}
[FBRequest requestForMyFriends]? – SEG