skip to Main Content

I am using the comment-id to get the from field and using the page access token:

[comment-id]?fields=from&access_token=[PAGE_ACCESS_TOKEN]

But I am not getting the desired output, I am getting back the comment-id only

{
  "id": "[comment-id]"
}

I am not getting what mistake I am making here.

Any help is appreciated.
TIA

2

Answers


  1. Use the {pagepost-id}_{comment-id} format instead.

    Example Request:-

    curl -i -X GET 
     "https://graph.facebook.com/v17.0/222277054012345_979370980112345?access_token=<YOUR_PAGE_ACCESS_TOKEN>"
    

    Response:-

    {
      "created_time": "2023-06-25T06:25:41+0000",
      "from": {
        "name": "John doe",
        "id": "111282025112345"
      },
      "message": "This is to explore FB comment API.",
      "id": "222277054012345_979370980112345"
    }
    

    Additionally, To get all the comments made on a Facebook page post you can use the following API call:-

    Request:-

    curl -i -X GET 
     "https://graph.facebook.com/v17.0/111282025112345_222277054012345/comments?access_token=<YOUR_PAGE_ACCESS_TOKEN>"
    

    Here in the URL, 111282025112345 is page_id and 222277054012345 is post_id.

    Response:-

    {
      "data": [
        {
          "created_time": "2023-06-25T06:25:41+0000",
          "from": {
            "name": "John doe",//Comment Author's name
            "id": "111282025112345"//Comment Author's id
          },
          "message": "This is to explore FB comment API.",
          "id": "222277054012345_979370980112345" //`{pagepost-id}_{comment-id}`
        }
      ],
      "paging": {
        "cursors": {
          "before": "MgZDZD",
          "after": "MQZDZD"
        }
      }
    }
    

    Hope this helps.

    Login or Signup to reply.
  2. In order to see data from other users and not your business, you need Advanced public_profile permission.

    https://developers.facebook.com/docs/permissions/reference/public_profile/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search