Search code examples
facebookfacebook-graph-apicommentsfacebook-comments

How to check if the facebook post is commentable


I am fetching the Facebook news feeds through API. User can comment on a post from website. but some posts doesnot allow the comment like Like Stories, add friend stories, change profile pic stories etc

How I can check that if the post allow the comment or not


Solution

  • The actions property of the post when you retrieve it from the API will show if the current (whose access_token you're using) user can like or comment on the post, e.g.

    /20531316728_167191526758558

    Contains:

    {
      "id": "20531316728_167191526758558", 
      "from": {
        "name": "Facebook", 
        "category": "Product/service", 
        "id": "20531316728"
      }, 
      "message": "Find your polling place on Facebook at http://bit.ly/Fbppl and then watch the nation vote in real time.", 
      "picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQCD6BNbTzxhmwEq&w=90&h=90&url=https%3A%2F%2Fs3.amazonaws.com%2FFacebookHackers-production%2Fissue4_data%2Fissue4_fb_og.png", 
      "link": "http://www.facebookstories.com/vote", 
      "name": "America Votes 2012", 
      "caption": "www.facebookstories.com", 
      "description": "Watch the nation vote in real time.", 
      "icon": "https://s-static.ak.facebook.com/rsrc.php/v2/yN/x/aS8ecmYRys0.gif", 
      "actions": [
        {
          "name": "Comment", 
          "link": "https://www.facebook.com/20531316728/posts/167191526758558"
        }, 
        {
          "name": "Like", 
          "link": "https://www.facebook.com/20531316728/posts/167191526758558"
        }
      ], 
    // (and more properties which aren't relevant