I've followed the guide here https://developers.facebook.com/docs/plugins/oembed/ and it works.
My question is, how can I get my post urls dynamically? so I can repeatedly use this endpoint for the number of posts I have
https://graph.facebook.com/v8.0/instagram_oembed?url={postUrl}&access_token={access_token}
The way the docs show is to hard code a url into the endpoint url, which seems redundant
There is currently no way to get all post URLs for an Instagram profile using the oEmbed API based on the documentation (or anywhere else on the web). You'll have to get all of the post shortcodes (links) by:
https://www.instagram.com/{profile_handle}/?__a=1
. There is a very strict rate limit these days, so it is highly recommended to cache the results the first time, maybe with local storage.[data].graphql.user.is_private
[data].graphql.user.edge_owner_to_timeline_media.edges.node
, get theshortcode
property.https://www.instagram.com/p/{shortcode}
.Alternatively, you could do a GET request to `https://www.instagram.com/{profile_handle} and use regex to get the a similar JSON object containing profile data in the HTML response like so:
The rate limit is strict here too so use be sure to cache. Testing can be a pain because you may have to change your IP address a couple times when you hit the rate limit.