How can I get an direct Instagram link from a twitter entity?

earl3s picture earl3s · Oct 2, 2012 · Viewed 10.5k times · Source

I have a twitter feed and I can find the instagram url in a tweet.

{
    indices: [
        90,
        110
    ],
    url: "http://t.co/kF9EXifn",
    expanded_url: "http://instagr.am/p/QC8hWKL_4K/",
    display_url: "instagr.am/p/QC8hWKL_4K/"
}

What I need is to take the expanded url from that object "http://instagr.am/p/QC8hWKL_4K/" and get the link to just the image itself, not the image on the Instagram site. Anyone know how to do that? Can I even derive the that link from the url?

Answer

John C picture John C · Oct 2, 2012

You can get just the image by appending /media/ to the URL. Using your example: http://instagr.am/p/QC8hWKL_4K/media/.

You can even specify a size,

One of t (thumbnail), m (medium), l (large). Defaults to m.

So for a thumbnail: http://instagr.am/p/QC8hWKL_4K/media/?size=t

Documentation here.