Instagram API停用转Graph API后,能否追踪媒体点赞数?
Absolutely! Now that you’ve converted your Instagram account to a business account and secured the necessary Graph API permissions, you can absolutely track media likes using the Instagram Graph API—this is the supported, modern replacement for the legacy Instagram APIs that are being deprecated.
Here’s a straightforward breakdown to get you up and running:
Required Permissions
First, confirm your access token includes these non-negotiable permissions:
instagram_basic: Grants access to core Instagram account data, including media details and like counts.pages_show_list(orpages_read_engagement): Needed to connect your linked Facebook Page (a mandatory requirement for Instagram business accounts on Graph API) and pull associated Instagram account data.
Step 1: Retrieve Your Instagram Business Account ID
Before accessing media data, you’ll need to get the ID of your Instagram business account by querying your linked Facebook Page:
GET /v18.0/{your-facebook-page-id}/instagram_accounts?fields=id,name
This request will return the unique ID for your Instagram business account, which you’ll use for all subsequent media-related calls.
Step 2: Fetch Media Like Counts
You have two flexible options depending on your needs:
Option 1: Get Likes for a Single Media Item
Use the specific Instagram Media ID to pull its like count directly:
GET /v18.0/{ig-media-id}?fields=id,like_count
A successful response will look like this:
{ "id": "17895695668004550", "like_count": 1234 }
Option 2: Bulk Fetch Likes for Multiple Media Items
To retrieve like counts for all recent media from your account in one go, include the like_count field in your media list request:
GET /v18.0/{ig-user-id}/media?fields=id,caption,like_count,timestamp
This returns a list of media objects, each with their respective like count attached.
Key Things to Keep in Mind
- Long-Lived Tokens: For ongoing tracking, convert your short-lived access token to a long-lived one (valid for 60 days) to avoid frequent re-authentication headaches.
- Insights for Granular Data: If you need more than just like counts (e.g., reach, impressions), use the
/{ig-media-id}/insightsendpoint with metrics likelike_count,comment_count, etc.—but the directlike_countfield on the media object is simpler for basic tracking needs. - Rate Limits: Be mindful of Graph API rate limits; batch requests are a great way to reduce the number of calls you need to make.
内容的提问来源于stack exchange,提问作者Sachin Trivedi

