penguin_P
penguin_P

Reputation: 93

How to get media-id from Instagram URL

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

Answers (2)

Nivethitha Thiyagarajan
Nivethitha Thiyagarajan

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)

  1. 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

  2. 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))
  1. then use the following url to get various metrics and media id https://graph.facebook.com/v11.0/{instagram_business_account_id}/media?fields=....&access_token=token

Upvotes: 0

GloryLanskoy
GloryLanskoy

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

Related Questions