Home » Javascript » How to get post_id with Facebook Share button?

How to get post_id with Facebook Share button?

Posted by: admin August 19, 2018 Leave a comment


I’ve put this code responsible for sharing posts on Facebook:

<a class="fb-share-btn"
    ng-href="https://www.facebook.com/sharer/sharer.php?u= + {{ url }}"
    onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;"
    target="_blank" title="Share on Facebook">

As described here: https://stackoverflow.com/a/20262460/6397554

And now, I would like to know how I can get post_id of the post that was shared. I really need to have this post_id to later count the post’s clicks. I guess maybe I could use some sort of a callback that receives post data.

Note: I’ve tried using Facebook API, but I need to allow my application users to share many different links on Facebook.