Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Facebook Media-id for instagram post from url

If I have a instagram post is there anyway to get the facebook id for an instagram post? To be clear, if I were to look at https://www.instagram.com/p/Bcqn51ynrd5/ I am able to find the instagram media-id by doing one of two things:

  • https://api.instagram.com/oembed/?callback=&url=https://www.instagram.com/p/Bcqn51ynrd5/
  • https://www.instagram.com/p/Bcqn51ynrd5?__a=1

However, neither of these are the media-id associated with facebook's new instagram graph insights. If I already have the facebook media-id I am able to get the instagram media-id through facebook graph by calling graph.facebook.com/{facebook-media-id}?fields=ig_id but I am unable to find the inverse. Is this possible?

like image 519
Alex Harris Avatar asked Mar 06 '18 23:03

Alex Harris


People also ask

What is media on Instagram?

Represents an image, video, or album.


2 Answers

Call graph.facebook.com/{instagram-business-account-id}/media?fields=ig_id

which returns a list of both Facebook and Instagram media-ids:

{
  "data": [
    {
      "ig_id": "1729885037886968354",
      "id": "16961190105043123"
    },
    {
      "ig_id": "1714698694055731973",
      "id": "16949739045077321"
    }
    ...

then find corresponding Facebook's media-id you can get the insights for.

Also, instead of ig_id use shortcode field in graph.facebook.com/{instagram-business-account-id}/media?fields=shortcode and traverse list searching directly for short code, so you may skip "finding Instagram media-id by short code" step.

like image 149
Victor Stagurov Avatar answered Sep 17 '22 13:09

Victor Stagurov


I don't think it is possible. It is listed as limitation in the Insights API documentation.

To list current limitations:

  • We only store 2 years worth of metrics data.
  • You can only get insights for a single Instagram Business account at a time.
  • You cannot get insights for Facebook Pages.
  • Stories insights are only available for 24 hours, even if the stories are archived or highlighted. If you want to get the latest insights for a story before it expires, set up a Webhook for the Instagram topic and subscribe to the story_insights field.
like image 23
tukan Avatar answered Sep 18 '22 13:09

tukan