Search code examples
phpfacebookapifacebook-graph-api

How to get facebook shares count with facebook api


i 'm coding in PHP. I need to make a website with facebook feed.

I can get like and comment with : https://graph.facebook.com/<id_post>?fields=picture,likes.summary(true).limit(0),comments.summary(true).limit(0)&access_token=;

but how can we get shares ? i've tried : https://graph.facebook.com/?id={url}&fields=engagement&access_token=<>

If i try facebook url "https://www.facebook.com" , i have the count of shares but how with our own facebook post, "https://www.facebook.com/id/posts/post_id" dont work

i have engagement -> share_count : 0 or i have 2 shares on the post.


Solution

  • As CBroe mentions:

    https://www.facebook.com/id/posts/post_id is not how you access the actual post via API. You need to use pageid_postid format. And engagement is for Open graph objects, for posts you need to look at the shares field.

    with ?fields=shares it's work