How to convert an Instagram ID to a URL in PHP

A simple PHP function to convert and existing Instagram ID (in the form of XXX_XXX) to the images direct URL

Over the last few years, Instagram has increasingly locked down their API to make it more difficult to fetch basic information about users feed without setting up a developers account.

It is fairly straight-forward to fetch an Instagram’s image ID from the Instagram API ( these look something like 843742765770251_748774120 ). Converting them into a direct URL ( i.e. https://www.instagram.com/p/BFBQEQDxVqV ) might seem fairly straightforward but Instagram really wants you to query their API again to look this up.

This seems a fairly complicated solution for a very simple task ( in my case, all I wanted to do is convert the ID into a direct link back to Instagram ).

Thankfully, Sean Lang cracked how Instagram generates its IDs back in 2015; and created a coffeescript to automate this and burried in stack-overflow is @ggwarpig excellent conversion of this principle into a simple PHP script.

A simple modified version of this is below; it will take an Instagram ID and output the full link to the image.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.