请求协助:适配Instagram API变更,通过用户名/ID获取动态
Hey there, I’ve dealt with this exact frustration before—Instagram’s private GraphQL endpoints are super flaky because they’re not meant for public use, and they love breaking after API updates. Here are the most reliable solutions to get back to fetching Instagram posts:
This is the only long-term, supported approach—no more sudden breakages from endpoint changes. Here’s what you need to do:
- Sign up for a Facebook Developer account, create a new app, and link it to your Instagram account(s)
- Choose the right API tier:
- Instagram Basic Display API: For personal Instagram accounts (lets you fetch your own posts or posts from users who authorize your app)
- Instagram Graph API: For business/creator accounts (more features for managing and fetching content)
- Request required permissions (like
user_profileanduser_mediafor personal accounts) - Use official endpoints to pull posts. For example, to get a user’s media:
GET /v18.0/{your-user-id}/media?access_token={valid-access-token}
Pro tip: Approval for the API might take a couple of days, but it’s worth it to avoid future headaches.
If you just need to display public posts on a website, Instagram’s embed tool is a quick, no-fuss option:
- You can manually generate embed code directly from any public Instagram post (click the three dots > Embed)
- For programmatic use, the oEmbed endpoint works too (you’ll need an app access token from the Facebook Developer platform):
GET /v18.0/oembed?url=https://www.instagram.com/p/{post-shortcode}/&access_token={app-access-token}
This is great for simple display cases without needing full API access.
If you don’t want to set up the official API yourself, some third-party tools offer Instagram data fetching. But keep these in mind:
- Pick services that explicitly state they use Instagram’s official API (avoid scrapers—they’ll break just like your old GraphQL endpoint)
- Check rate limits and pricing (many have free tiers for small projects)
- Always review their privacy policy, especially if you’re handling user-specific data
Stay away from scraping private endpoints like the GraphQL one you were using. Instagram actively detects and blocks these, and they change the structure constantly—you’ll just keep hitting the same wall every few months. For commercial apps, the official API is mandatory to avoid legal issues and service disruptions.
内容的提问来源于stack exchange,提问作者akash99

