Reputation: 93
how can I get the media-id of a instagram posting from the url?
For example I need the media-id for https://www.instagram.com/p/Cf4dPucLzW0/
Solutions that does not work anymore:
Upvotes: 3
Views: 4264
Reputation: 1313
you need to have pageid, access token and an short code (which can be extracted from the URL you have for eg if this is the url :https://www.instagram.com/reel/Cs12TgIv8Ns/. "Cs12TgIv8Ns" is the short code)
then you can use the page id to convert to instagram business id using the following url: url = Graph + endpoint + '?fields=' + instagram_business_account + '&access_token=' + Token
convert the short code to
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
media_id = 0
for letter in short_code:
media_id = (media_id * 64) + alphabet.index(letter)
IG_id_list.append(str(media_id))
Upvotes: 0
Reputation: 41
Put the following at the end of the post: ?__a=1&__d=dis
, e.g.:
https://www.instagram.com/p/Cf4dPucLzW0/?__a=1&__d=dis
Upvotes: 4