Skip Navigation

Intro Getting Images from Instagram with PHP

In this episode, we will introduce you to a super simple way to get the latest post from a public Instagram account.

Transcript

Hello, and welcome to code time. My name is Trevor Greenleaf in this series. We're going to be covering the Instagram API. Well kind of sorta, I'm going to show you a really simple way to pull images from your Instagram account onto your website, or maybe just loop through them in PHP. So yeah, we're going to be using PHP just straight PHP. No CMS, no WordPress. No, Laravel just good old PHP composer of course, though, to get a package. And we're going to show you a really simple way to pull your images from Instagram. So I'm currently on instagram.com/trevor Greenleaf, and you're going to see my Instagram profile here and in its current state, it is pretty much yes. Photos of Bubba. Do my son, or you could say my cat anyway. So here I'm going to get us started in this series to pull that data from there and loop through it and put it into a, a, a website.

Maybe I'll apply bootstrap to it and format it a little bit. So you can kind of get used to how you might work with the data here. Now, there is the Instagram API there, uh, and I think they're on version two now. And there are a couple of libraries out there. There's a PHP library, a Python library that you could go and use to, uh, and actually call, uh, specific URLs to request. And of course you could always look at the URL end points as well on any API. And, uh, it, that method you will need to set up auth keys and a bunch of other stuff to get configured, and that I'm not going to cover. So here, I'm just going to show you the really simple way, pull data and loop through the data without OAuth he's, without all that other stuff, just real easy now, knowing that, uh, that means you can't pull data from a user, uh, specific typically, um, that isn't public data. So if I have a private account, maybe you want to grab my data or the number of likes that I have. You would need me to approve that via the OAuth key signature and the regular Instagram API. So if you're going down that route, definitely check out the Instagram API. Uh, if you just, Hey, you know what? I just want to show cool photos on my, uh, on my website. Well, well then this is the way to go and do it. So let's go ahead and get started.