Get an Instagram Image URL
After learning how to implement
larabros/elogram into Laravel, I discovered that they are only needed if you want to interact with the private API of Instagram to authenticate a user and perform actions with its account (e.g. like images, post content, comment, etc.).
If you — like me — just want to obtain the URL of Instagram media, such as an image, you can do the following with public access (no authentication or access_token needed), which, compared to services like Flickr, offer a pretty low resolution of just 1080 by 1080 pixels.
So, let's get to it.
Instagram provides three different sizes of each image you upload, i.e. thumbnail, medium, and large. If you were to access those images of the following picture on Instagram,
https://www.instagram.com/p/BI0BQkfh0ed, you would do as follows.
// Thumbnail https://www.instagram.com/p/BI0BQkfh0ed/media/?size=t // Medium https://www.instagram.com/p/BI0BQkfh0ed/media/?size=m // Large https://www.instagram.com/p/BI0BQkfh0ed/media/?size=l
The last letters—t, m, and l—represent the size of the image. These links redirect to the Instagram media's URL of the size you specify, and can be used as the
src attribute on an HTML
img, or as a way to download Instagram pictures.