In my app I wanna explicitly show number of likes for any particular post. Is there a API call available to get this info using the POST ID from FaceBook?
I located solution for this myself. This is how I did
- (IBAction)likes_count:(id)sender {
[self requestGraph: @"123456789876543?fields=likes.limit(1000)" sender:^(int count) {
textView.text = [NSString stringWithFormat:@"%d", count];
likesCount = 0;
}];
}
-(void)requestGraph: (NSString*) fbRequest sender: (void (^)(int count))callback {
likes_count.enabled = FALSE;
FBRequest *like = [FBRequest requestForGraphPath:fbRequest];
[like startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(likesCount == 0)
likesCount = [result [@"likes"][@"data"] count];
else
likesCount = likesCount + [result [@"data"] count];
if (result [@"likes"][@"paging"] [@"next"] != NULL) {
[self requestGraph:[result [@"likes"][@"paging"] [@"next"] substringFromIndex:27] sender:callback ];
}
else if (result [@"paging"] [@"next"] != NULL)
[self requestGraph:[result [@"paging"] [@"next"] substringFromIndex:27] sender:callback];
else {
callback(likesCount);
likes_count.enabled = TRUE;
}
}];
}