user43103
user43103

Reputation: 41

Instagram Graph API - Get comments for media

I am trying to get comments for some business account by using business discovery node. I can load list of media with the request

GET https://graph.facebook.com/v3.1/17841402914723639?fields=business_discovery.username(bluebottle){followers_count,media_count,media{media_type,comments_count}}

This returns

{
  "business_discovery": {
    "followers_count": 297515,
    "media_count": 1317,
    "media": {
      "data": [
        {
          "media_type": "IMAGE",
          "comments_count": 18,
          "id": "17970528943031455"
        },
        {
          "media_type": "IMAGE",
          "comments_count": 17,
          "id": "17938949563163035"
        },
        {
          "media_type": "IMAGE",
          "comments_count": 66,
          "id": "17966264041064104"
        },

I assume the id in the media entry is an id for that object. But when I am trying to access it like

GET https://graph.facebook.com/v3.1/17970528943031455

I got an error

{
  "error": {
    "message": "Unsupported get request. Object with ID '17970528943031455' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
    "type": "GraphMethodException",
    "code": 100,
    "error_subcode": 33,
    "fbtrace_id": "HbaasWNQ8ko"
  }
}

Is it permission problem? How can I get list of comments for a media?

Upvotes: 0

Views: 3808

Answers (2)

minaz
minaz

Reputation: 5780

You can only get comments if you have a valid authentication token for the account you are querying. You would use the /media or <media_id>/comments endpoint to get comments, insights, etc:

Media endpoint

/MY_IG_BUSINESS_ACCOUNT_ID/media?fields=id,caption,comments_count,children{media_url},comments.limit(50){id,timestamp,username,text},insights.metric(impressions,reach,engagement,saved,video_views)&limit=30

Comments endpoint:

/<MEDIA_ID>/comments/?fields=created_time,from,message,like_count&limit=50

Upvotes: 0

Matheus Tosta
Matheus Tosta

Reputation: 101

According to the documentation: "An access token from a User who created the IG Media object, with the following permissions:" means that you need to have access permission granted by the owner of the post to have access to its comments.

Upvotes: 1

Related Questions