I want to fetch Facebook logged in user's interests and likes, which I'm able to do. But I'm not getting the image for pages liked by user or image for user interests.
The following code lets me fetch user likes:
[FBRequestConnection startWithGraphPath:@"/me/likes"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(@"User interests data: %@",result);
}];
which returns the following json data:
data = (
{
category = "Musician/band";
"created_time" = "2014-08-08T05:09:56+0000";
id = 9770929278;
name = Adele;
},
{
category = "Musician/band";
"created_time" = "2014-08-08T05:02:09+0000";
id = 5027904559;
name = Shakira;
}
);
but, I want images for the pages liked. How can I do that? Any help would be appreciated. Thanks in advance.
You can execute 1 more Graph API call for each for the likes:
[FBRequestConnection startWithGraphPath:@"/me/likes"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSArray *data = [result objectForKey:@"data"];
for(NSDictionary *liked in data) {
NSString *page_id = [liked objectForKey:@"id"];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"/%@/picture", page_id] parameters:nil HTTPMethod:@"GET" completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// Get your profile pic here
}
}];
}
}];
It will return the public details of Page. See documentation for more information.