Saurabh
Saurabh

Reputation: 433

How to get Facebook post id?

I am making an iPhone app in which Facebook post sharing option is available. Now I want to show all the likes and comments of that post. I know that we can do it through http://graph.facebook.com/post_id/comments . Now can you tell me how to get the post_id of my post or shared link?

Thanks.

Upvotes: 0

Views: 1463

Answers (2)

C Abernathy
C Abernathy

Reputation: 5513

Assuming your app posts to the me/feed endpoint, using the Facebook SDK 3.1 you can set up a completion handler to grab the post id:

[FBRequestConnection
 startWithGraphPath:@"me/feed"
 parameters:self.postParams
 HTTPMethod:@"POST"
 completionHandler:^(FBRequestConnection *connection,
                     id result,
                     NSError *error) {
     if (error) {
         // Handle error
     } else {
         NSString *postId = [result objectForKey:@"id"];
     }
 }];

See: https://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/ for an example of how to post.

Upvotes: 0

Manu
Manu

Reputation: 4750

When you post anything on facebook. In your

- (void)request:(FBRequest *)request didLoad:(id)result

method you will get the result.. Just print that result. You will get the post_id if you are using FB SSO

Upvotes: 1

Related Questions