skip to Main Content

I am trying to create a Facebook app that can pull down the comments on the posts of a business page I have created. I have successfully created the app and connected my Facebook page through OAuth. However, none of the comments on the page’s posts are coming through. Any help would be appreciated, please see below code.

https://graph.facebook.com/v3.2/{pageId}/?access_token={accessToken}&fields=id,name,posts

Response:

{
    "id": "{pageId}",
    "name": "Page Name",
    "posts": {
        "data": [
            {
                "created_time": "2016-01-15T19:46:28+0000",
                "message": "POST 1",
                "id": "47829695884833182_111061999222282539"
            },
            {
                "created_time": "2016-01-15T19:45:56+0000",
                "message": "POST 2",
                "id": "4734458296958848182_111061922795615892"
            }
    }
}

The same thing happens if I use the following endpoint:

https://graph.facebook.com/v3.2/{pageId}/feed?access_token={accessToken}

Or

https://graph.facebook.com/v3.2/{pageId}/posts?access_token={accessToken}

I found a reference showing I may be able to get comments through this endpoint:

https://graph.facebook.com/v3.2/{pageId}/comments?access_token={accessToken}

However I get the following response:

{
    "error": {
        "message": "(#100) Tried accessing nonexisting field (comments) on node type (Page)",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "EN938TNAHM6"
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    I was able to get comments by using the following request:

    https://graph.facebook.com/{post_id}/comments?access_token={accessToken}&summary=true
    

    post_id looks something like this - 57042555475_57045425233226

    You have to get comments by posts not pages so first you need to make a call to get all your posts and then make a call for each post to get comments.


  2. With all but the last request you are not asking for comments anywhere. And with the last one you are trying to ask for comments on the page object itself, which are not a thing.

    You need to ask for the comments, on either the feed or posts endpoint:

    /{pageId}/feed?fields=comments
    
    /{pageId}/posts?fields=comments
    

    And if you want to get other info about the page as well in the same request, you can use Field Expansion syntax,

    /{pageId}?fields=id,name,posts{comments}
    

    (Any other fields of the posts you might want besides the default id, you’d need to list there comma separated – posts{message,comments,...})

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