如何通过Instagram Graph API及访问令牌获取Instagram关注列表(尝试无效)
Hey there! I see you've been struggling to pull an Instagram account's following list—those old unofficial endpoints like https://www.instagram.com/urvish_._/?__a=1 are long dead, so let's walk through the proper, official way using the Instagram Graph API.
First, Critical Prerequisites
Before diving into API calls, you need to check these non-negotiable boxes:
- Your target Instagram account must be a Business or Creator Account (personal accounts aren't supported by the Graph API).
- The account must be linked to a Facebook Page (this is mandatory for accessing Instagram data via the Graph API ecosystem).
- You need the correct permissions attached to your access token:
instagram_basic(for basic profile data) andpages_read_engagement(to access Page-linked Instagram accounts).
Step-by-Step Implementation
Retrieve your Instagram User ID
First, you need the unique ID of the Instagram account you're targeting. Grab it by querying your linked Facebook Page's endpoint:GET /{facebook-page-id}/instagram_accounts?access_token={your-access-token}The response will include an
idfield—this is your Instagram User ID (sometimes labeledig_id).Generate a Long-Lived Access Token
Short-lived tokens expire after 1 hour, so create a long-lived one (valid for 60 days, renewable) using this endpoint:GET /oauth/access_token?grant_type=fb_exchange_token&client_id={your-app-id}&client_secret={your-app-secret}&fb_exchange_token={your-short-lived-token}Guard this token securely—it's the key to making valid API requests.
Fetch the Following List
Now call the official endpoint to get the following list. You can specify which user data you want (like username, profile picture) in thefieldsparameter:GET /{instagram-user-id}/following?fields=id,username,full_name,profile_picture_url&access_token={your-long-lived-access-token}
Why Your Old Attempts Failed
The __a=1 endpoint was an unofficial, internal API that Instagram has completely deprecated and blocked. Using it will return empty data, errors, or get your requests throttled—so stick strictly to the official Graph API methods.
Common Pitfalls to Avoid
- Missing Permissions: A
403 Forbiddenerror almost always means your token lacksinstagram_basicorpages_read_engagement. - Expired Token: Always use a long-lived token and renew it before it expires to avoid unexpected failures.
- Personal Account Limitation: If you're working with a personal Instagram account, convert it to a Business or Creator Account first—there's no way around this for the Graph API.
内容的提问来源于stack exchange,提问作者Savan Patel

