0

I am using this line of code for getting count of likes on facebook post

NSString *postId = @"1234567890_1234567890";
NSMutableDictionary* photosParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:postId,@"ObjectId",nil];

NSString * str = (NSString *) [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/{object-id}/likes"
                                   parameters:photosParams
                                   HTTPMethod:@"GET"]
 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
     if ([error.userInfo[FBSDKGraphRequestErrorGraphErrorCode] isEqual:@200]) {
         NSLog(@"%@",[error localizedDescription]);
     }
 }];

but I am getting error of unsupported url, any one have Idea what parameter I use to get result. I am using updated version of facebook api

Moxy
  • 4,162
  • 2
  • 30
  • 49
shareInfo
  • 11
  • 4

1 Answers1

1

As

states, you need

The same permissions required to view the parent object are required to view likes on that object.

That means that the permission setting for Posts (https://developers.facebook.com/docs/graph-api/reference/v2.3/post) apply:

  • For page posts, public posts by the page are retrievable with any valid access token. Posts by people on the page, posts by people which mention the page, or targeted page posts (by language or geography, for example) may require a user or page token.
  • A user access token with read_stream or user_posts permission for any other posts

Are you sure you're adding an Access Token to your request?

You can request multiple posts at once like this:

/?ids={object_id1},{object_id2}&fields=id,created_time,likes.summary(true).limit(0)
Tobi
  • 31,405
  • 8
  • 58
  • 90
  • yes I am sure that I am adding an Access Token in my request, but i am not getting what type of parameter I add in my request. – shareInfo May 04 '15 at 08:51
  • this is the line which i m requesting )> – shareInfo May 04 '15 at 08:57
  • `{object-id}` must be replaced with the actual `ObjectId` (1234567890_1234567890) – Tobi May 04 '15 at 09:05
  • thanks, it works. may i send more then one ObjectId at a single time? – shareInfo May 04 '15 at 09:16
  • Thanks Tobi for suggestion. – shareInfo May 04 '15 at 10:33
  • @Tobi this gives me only id not likes ..133232423263871/?fields=likes.summary(true).limit(0).....i don't know what i am missing..{ "id": "133232423263871" }...I am trying it here developers.facebook.com/tools/explorer – Dragon Aug 31 '15 at 09:15
  • @Sadaquat You're trying this with a User as Object Id. This means you need to gather the `user_likes` permission of the respective user first. See `/134138870263871?fields=metadata{type}&metadata=1` – Tobi Aug 31 '15 at 09:21
  • @Tobi yes i have the permission user_likes , and i can access all the data ,i am testing it on my demo facebook id, but i am unable to get total_like_count, i have tried different formats and nothing works...and the ..133232423263871/?fields=likes.summary(true).limit(0) this just returns id not count..i am using the latest v2.4 – Dragon Aug 31 '15 at 09:55
  • @tobi yes it works but it gives me all the likes not total-like-count, i have asked another question on stackoverflow that might help you to see whats wrong, plz see this..http://stackoverflow.com/questions/32309278/get-facebook-total-like-count-of-a-user – Dragon Aug 31 '15 at 10:37
  • Thanks for your time. – Dragon Aug 31 '15 at 10:50