Question

Is it even possible to retrieve comments on Facebook ads through the API (Graph or FQL)? If yes, do I need a whitelisted app to do it? Also, if I have a page access token, is it enough, or I need a user access token with ads_management permission?

Was it helpful?

Solution 2

You can't pull the actual words of the comment via the API - would make it too easy to scrape.

OTHER TIPS

Regarding the token usage, a page_token is extended by a given user to a given app. The page_token will have at most the same privileges as the user on his authorized pages and ad_accounts.

Generating a page_token can be done automatically, in behalf of the user, if you already have a user_token with manage_pages permission. Again, this page_token will have at most the same privileges that the user_token you used to generate it.

In other words, having a page_token doesn't amount for any additional privileges than the ones already present in the user_token.

Having said that, you need

  1. a token with access to a given ad_account
  2. that the app for which that token was generated, has that ad_account active in its settings

If the second requisite isn't met, for example for ad_account act_123456789 you'll get the error:

{
  "error": {
    "message": "(#274) The ad account is not enabled for usage in Ads API. Please add it in developers.facebook.com/apps -> select your app -> settings -> advanced -> advertising accounts -> Ads API. Account 123456789 not enabled for this application.",
    "type": "OAuthException",
    "code": 274,
    "fbtrace_id": "xxxxx"
  }
}

You can try, for example, generating a token with all privileges for the Graph API Explorer App. It will throw the error above because said App doesn't have the ad_account act_123456789 enabled.

So, given you have a token with ads_read extended for an app that has this ad_account listed, and you know the ad_id, you can procede as I explained in thread Get comments from facebook ads (marketing)

Basically, you use the ad_id (for example 123000000) to get the promoted post id and its actions

/123000000?fields=creative.fields(effective_object_story_id),insights.fields(actions)

The answer will contain an effective_object_story_id (for example, let's say it is 456000000_789000000) and its actions broken down by type:

{
  "creative": {
    "effective_object_story_id": "456000000_789000000",
    "id": "123000000"
  },
  "insights": {
    "data": [
      {
        "actions": [
          {
            "action_type": "comment",
            "value": "12"
          },
          {
            "action_type": "like",
            "value": "2"
          },
          {
            "action_type": "post",
            "value": "3"
          },
          {
            "action_type": "post_reaction",
            "value": "29"
          },
          {
            "action_type": "video_view",
            "value": "558"
          },
          {
            "action_type": "page_engagement",
            "value": "604"
          },
          {
            "action_type": "post_engagement",
            "value": "602"
          }
        ],
        "date_start": "2017-08-14",
        "date_stop": "2017-08-20"
      }
    ],
    "paging": {
      "cursors": {
        "before": "xxx",
        "after": "xxx"
      }
    }
  }
}

If you want to also distinguish paid comments from regular comments, you can query the comments edge of the post_id 456000000_789000000 to get the overall comment count which should be greater than the comments generated by the ad.

Yes, Facebook ads that have comments are because the ad is a promoted page post, whether that page post is hidden or not. Page post comments are available via the Facebook API and does not require having Ads API access. Use the graph API endpoint /v2.1/{page-id}/comments to retreive page post comments. See the Facebook Graph API documentation on object comments for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top