Get comments from facebook ads (marketing)

2019-07-18 02:15发布

After I make an ads for my post on facebook ads manager. Facebook Ads Manager show me how many comment belong to this ads. This is very important for me to verify the effective of my campaign.

In programing aspect: Is there's any way to count number belong to my ads like Facebook Ads Manager (I describe above). I have used both Java Facebook Ads SDK (Ads Insight module from https://github.com/facebook/facebook-java-ads-sdk) and Graph Explorer Tool, they both return "comment" field or "like" field not existed Please help!

2条回答
劫难
2楼-- · 2019-07-18 02:30

You can't get comments nor reactions from Marketing Insights directly.

I stand corrected. If you have access to an ad_account insights, then you can use Marketing API to get a post's comments directly. Thanks @lamxung55

Let's say you have and ad_id of 123000000

If you have a token with ads_management or ads_read permission, you can make a request to the Marketing API such as

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

This will give you the effective_object_story_id which is the object_id of the post ({page_id}_{post_id}), and its insights including its actions broken down by action type. For example:

{
  "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"
      }
    }
  }
}

The effective_object_story_id (so, post_id) is 456000000_789000000.

You can then query the comments edge of the post adding summary=true as a parameter. This endpoint is public for common posts (however, it won't work for non public posts)

/456000000_789000000/comments?summary=true

Which will respond with an object like

{
  "data": [
     <LOTS OF COMMENTS HERE>
  ],
  "paging": {
    <PAGING LINKS>
  },
  "summary": {
    "order": "chronological",
    "total_count": 50,
    "can_comment": true
  }
}

This means the post has had 50 comments, of which 12 were made through a paid action.

查看更多
仙女界的扛把子
3楼-- · 2019-07-18 02:42

We can simply use this syntax to get adset comment: ...adset_id/insights?fields=actions. Another ads stuffs are the same

查看更多
登录 后发表回答