I have created an application in Xcode 4.5. It incorporates a Facebook login process, a query of my friends and their basic info and some newsfeed publishing processes successfully. However, I am having an issue in trying to query which of my friends have "liked" a certain Facebook object, in this case, a photo. Here is what I have done thus far:
Requested the following permissions in the - (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI method:user_about_me, read_friendlists, friends_likes, read_stream, friends_likes, user_likes, friends_photos,user_photos.
I went on Facebook and found a photo that has been liked by some of my Facebook friends. I then investigated the id of the photo by going to https://graph.facebook.com/?ids=https://www.urlToFBPhoto
I used the following query code (as per the facebook developer page regarding such queries: url) SELECT user_id FROM like WHERE object_id="10152365284110475".
I was expecting that when I did an NSLog of the resulting data from this query, I would get uids of the few friends who I know like the photo. But instead, the query returned no results whatsoever.
For clarity, here is the full query code I used:
- (IBAction)getFriendLikes:(id)sender
NSString *objectID = @"10152365284110475"; //object id of a friend's FB photo
NSString *query = [NSString stringWithFormat:
@"{"
@"'friendlikes':'SELECT user_id FROM like WHERE object_id=%@'," //no data
//@"'friends':'SELECT uid2 FROM friend WHERE uid1 = me()'," //returns data
//@"'friendinfo':'SELECT uid, name, sex, pic_big, pic_square FROM user WHERE uid IN
//(SELECT uid2 FROM #friends)'," //returns data
@"}",objectID];
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:
query, @"q", nil];
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Result: %@", result);
}
NSArray *friendInfo = (NSArray *) [[[result
objectForKey:@"data"]
objectAtIndex:1]
objectForKey:@"fql_result_set"];
[DataController dc].fbArray = nil;
[DataController dc].fbArray = friendInfo;
//post callback tasks
} ];
}
If anyone can offer any assistance I would greatly appreciate it!