You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python调用Instagram评论接口仅获取自身评论的问题咨询

Instagram Comments API: Why Can't I See Other Users' Comments?

Great question—let's break down why you're only seeing your own comments and how to fix this.

First off, the https://api.instagram.com/v1/media/{media-id}/comments endpoint you're using is part of the deprecated Instagram Legacy API (v1). This old API has strict limitations on data access, which is why you're restricted to only your own comments. Legacy endpoints are no longer supported for new apps and have severely narrowed functionality these days.

Here's what you need to do to fetch all user comments:

1. Switch to the Instagram Graph API

Instagram now requires using the Instagram Graph API (current latest version is v18.0) for most data retrieval tasks, including pulling all comments on a media post. This is the supported, fully-featured replacement for the old v1 API.

2. Secure the Right Permissions

To access all comments on a post, you'll need specific permissions depending on your account type:

  • For Business/Creator Instagram Accounts (linked to a Facebook Page):
    • pages_show_list (to access your linked Facebook Pages)
    • pages_read_engagement (to retrieve engagement data like comments)
  • For Personal Accounts: Convert your account to a Creator or Business account first, then request the instagram_basic permission. Note: Private posts will only show comments from users who follow you.

3. Python Implementation Example

Here's a straightforward script using the requests library to fetch all comments via the Graph API:

import requests

def fetch_instagram_comments(media_id, access_token):
    api_url = f"https://graph.facebook.com/v18.0/{media_id}/comments"
    request_params = {
        "access_token": access_token,
        "fields": "id,text,from{id,username},created_time"  # Customize fields as needed
    }
    
    response = requests.get(api_url, params=request_params)
    
    if response.status_code == 200:
        return response.json()
    else:
        error_msg = response.json().get('error', {}).get('message', 'Unknown error')
        print(f"Request failed: {error_msg}")
        return None

# Usage example
your_media_id = "YOUR_MEDIA_ID_HERE"
your_access_token = "YOUR_VALID_ACCESS_TOKEN_HERE"

comments_data = fetch_instagram_comments(your_media_id, your_access_token)
if comments_data:
    print("All comments:")
    for comment in comments_data["data"]:
        username = comment["from"]["username"]
        text = comment["text"]
        print(f"@{username}: {text}")

4. Quick Checks to Avoid Headaches

  • Confirm your access token is valid and includes the required permissions (you can use Facebook's Access Token Debugger to verify this).
  • If the post is private, make sure your app/account has permission to view it (e.g., you follow the user if it's someone else's private post).
  • Double-check that the media ID corresponds to a post linked to the account associated with your access token.

内容的提问来源于stack exchange,提问作者oharr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:36:06