我的Facebook登錄解析工作完全沒有問題,但生成的訪問令牌沒有顯示好友列表的權限,雖然我在登錄時給予該權限。當我使用Facebook Graph API'Friendlists'(fbID/friendlists)並且響應數組爲空時,我開始知道。因此,也使用生成的相同訪問令牌運行Graph API Explorer。它不告訴我任何錯誤和數據陣列是相同的空白,並與解析'pfloginviewcontroller'某些Facebook權限不能在ios中工作
調試信息「領域‘好友列表’僅在用戶對象上的用戶授予「read_custom_friendlists的許可後,訪問」
這是我使用的方法
WLLoginViewController *login = [[WLLoginViewController alloc]init];
login.fields = PFLogInFieldsFacebook;
NSArray *permission = [[NSArray alloc]initWithObjects:@"email",@"read_custom_friendlists",@"publish_actions",@"user_location",@"user_hometown",@"user_website",@"user_about_me",@"user_photos",@"user_friends",@"read_custom_friendlists", nil];
login.facebookPermissions = permission;
WLLoginViewController繼承PFUserLoginManager,我從其他類調用它。
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"permissions%@",logInController.facebookPermissions);
if(result) {
if ([result valueForKey:@"hometown"]) {
NSString *nn = [[result valueForKey:@"hometown"] valueForKey:@"name"];
[user setValue:[[result valueForKey:@"hometown"] valueForKey:@"name"] forKey:@"hometown"];
}
if ([result valueForKey:@"location"]) {
[user setValue:[[result valueForKey:@"location"] valueForKey:@"name"] forKey:@"location"];
}
[user setObject:[result valueForKey:@"id"] forKey:kWLUser_FacebookId];
[user setObject:[result valueForKey:@"name"] forKey:kWLUser_Name];
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if([PFInstallation currentInstallation]) {
// save in background current installation.
[[PFInstallation currentInstallation] setObject:user forKey:@"user"];
[[PFInstallation currentInstallation]saveInBackground];
}
}];
[[ParseManager sharedInstance]saveDeviceToken:[[NSUserDefaults standardUserDefaults]objectForKey:@"DeviceToken"]];
[self dismissViewControllerAnimated:YES completion:nil];
}else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Could not login" message:@"Could not login to facebook, please try again" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
}];
} 這是這是其當在代碼的用戶返回到應用程序從facebook.The的NSLog是示出了許可完美其中我給運行方法。
最後,這是用於處理Facebook的要求 方法 - (無效){handleFacebookFriendsRequest
NSString *queryParams = @"id,name,picture.width(350).height(250),location,hometown,likes.limit(100000),statuses.limit(1),languages";
[queryParams stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",[FBSession activeSession].permissions);
NSLog(@"%@",[[FBSession activeSession].permissions description]);
NSLog(@"%@",[FBSession activeSession].accessTokenData.accessToken);
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"me/friends?fields=%@",queryParams] completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
//change For getting everything out
NSLog(@"%@",[result objectForKey:@"data"]);
[[ApplicationDataModel sharedInstance]setFacebookFriendsList:[result objectForKey:@"data"]];
[self facebookRequestDidLoad:result];
} else {
[self facebookRequestDidFailWithError:error];
}
}];
}
我被困急需幫助。
否我必須將該朋友列表顯示給用戶,以便他可以向他們發送邀請加入我們的應用程序。 –
我必須爲此請求read_custom_friendlists嗎?我添加了'user_friends',它只是將我的應用程序管理員的好友列表帶給我..這裏應該是什麼問題? –