我试图通过发送 FBRequest 来获取朋友的生日、位置和姓名,并将结果显示在不同视图的表格上。但我总是收到零回应。我首先设置了权限,然后创建了一个包含必填字段的请求:
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_birthday",@"friends_hometown",
@"friends_birthday",@"friends_location",
nil];
if (!FBSession.activeSession.isOpen) {
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
} else if (session.isOpen) {
NSLog(@"permissions::%@",session.permissions);
NSLog(@"Open");
FTBFriendTableViewController *ftbFriendTableViewController= [[FTBFriendTableViewController alloc] initWithNibName:@"FTBFriendTableViewController" bundle:nil];
FTBAppDelegate *delegate=(FTBAppDelegate*)[[UIApplication sharedApplication] delegate];
if (ftbFriendTableViewController.friendList == nil){
ftbFriendTableViewController.friendList = [[NSMutableArray alloc] init];
}
FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,birthday,location"];
[ friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
ftbFriendTableViewController.friendList = [result objectForKey:@"data"];
for (FBGraphObject<FBGraphUser> *friend in test) {
NSLog(@"%@:%@", [friend name],[friend birthday]);
}}];
delegate.window.rootViewController = ftbFriendTableViewController;
}
}];
return;
}
我还在应用程序 plist 中设置了 FacebookAppID、FacebookDisplayName 和 URL 标识符。这是发送的实际请求:
FBRequest: 0x94c1080, session: 0xa1c5600, graphPath: me/friends?fields=name,birthday,location, HTTPMethod: GET, 参数: { "migration_bundle" = "fbsdk:20130409"; }
知道还有什么会导致无响应问题吗?谢谢!