Get all comments of a Facebook Page using Graph API

174 Views Asked by At

Is there any way modify/alter the Grap API calls such that it returns all the comments of all the posts from a Facebook page. I know that there is no direct API call for that.

I am using the following call : /{page-id}/feed/?fields=comments%7Bmessage%7D&limit=5&access_token=xxxxxxxxxx

The result it returns also has ids of posts that does not have any comment. The JSON is as follows :

{
  "data": [
    {
      "id": "{page-id}_{post-id}"
    },
    {
      "id": "{page-id}_{post-id}"
    },
{
      "comments": {
        "data": [
          {
            "message": "Good work. keep it up..",
            "id": "{post-id}_280247294578029"
          }
        ],
        "paging": {
          "cursors": {
            "before": "MQZDZD",
            "after": "MQZDZD"
          }
        }
      },
      "id": "{page-id}_{post-id}"
    },
    {
      "id": "{page-id}_{post-id}"
    },
    {
      "id": "{page-id}_{post-id}"
    }
  ],
  "paging": {
    "cursors": {
      "before": "yyyyyy",
      "after": "zzzzzz"
    },
    "next": "https://graph.facebook.com/v16.0/{page-id}/feed?access_token=xxxxx"
  }
}

Is there a way to remove the

{
      "id": "{page-id}_{post-id}"
}

where there is not a single comment.

Any help would be appreciated.

TIA.

0

There are 0 best solutions below