I am trying to retrieve Posts, statuses, and photos in which a user has been tagged at a location, using the locations in user connections. The problem is that while using the proper permissions and getting the demanded results in Graph Api Explorer the same does not happen in my app. The response only returns with the user id missing the location key. The code i use is the following:
For permissions:
NSArray *permissions = [[NSArray alloc] initWithObjects:@"friends_status",@"friends_photos",nil];
if (!FBSession.activeSession.isOpen) {
// if the session is closed, then we open it here, and establish a handler for state changes
[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) {
[self pickFriendsButtonClick:sender];
}
}];
return;
}
To retrieve data:
for (int i = 0; i < [selectedFbFriends count]; i++) {
NSString *path = [NSString stringWithFormat:@"me/friends/%@?fields=locations",selectedFbFriends[i]];
FBRequest *friendRequest = [FBRequest requestForGraphPath:path];
[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id<FBGraphObject> result, NSError *error) {
NSLog(@"%@",result[@"data"]);
}
The result is not the same as using the same path in Graph Api Explorer. I only get the user id. My head is gonna burst because i can not find what is wrong and the permission seem to be proper ones. Any help out there would be much appreciated. :)
Seems like that function doesn't consider the parameters as a part of the path. You can use this:
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate;
source: https://developers.facebook.com/docs/reference/iossdk/request/
where params will be:
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:@"locations" forKey:@"fields"];