Search code examples
facebook-graph-apiinstagram-graph-api

retrive instagram media comments using graph api business discovery


I am using this URL to retrieve information from a third-party business account:

MY_IG_BUSINESS_ACCOUNT_ID?fields=business_discovery.username(digikalacom){media.limit(5){comments_count}}

The trouble is when I include comments in the media query (after comments_count) I get this error:

{
    "error": {
       "message": "(#100) Please read documentation for supported fields.",
       "type": "OAuthException",
       "code": 100,
       "fbtrace_id": "A8QnXYZlrudpxF8xhdZsSYf"
    }
}

The documentation provided for business_discovery doesn't mention anything about the actual list of comments. It only includes comments_count.

Here is the list of permissions I'm using for my app:

read_insights
pages_show_list
ads_management
business_management
instagram_basic
instagram_manage_comments
instagram_manage_insights
pages_read_engagement
pages_manage_metadata

So I cannot say for sure. whether it's a permission problem or IG graph API does not work that way for comments. So any thoughts on how I can get a list of comments for a third-party IG account's media using graph API?


Solution

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

    /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