Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,410 members, 7,836,640 topics. Date: Wednesday, 22 May 2024 at 10:52 AM

Display Instagram Feeds On Your Website - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Display Instagram Feeds On Your Website (968 Views)

Test-run My Math Algorithms Open Display Library Site / Android, How To Display Image In Image View From Mysql / Already Exist Dont Display 3000 k naira for who can solve it (2) (3) (4)

(1) (Reply)

Display Instagram Feeds On Your Website by Nobody: 2:41pm On May 20, 2016
How To: Instagram API + Fancybox Simplified

api / development / instagram / photos Posted on Jun 12, 2012 by Nick Rivers

So the last tutorial I posted demonstrated how to render Foursquare checkins on a google map. In this tutorial, I will demonstrate how to display your Instagram photos on your blog or website. Coincidentally, at its core Instagram uses Foursquare's API for associating "venues" with a photo. For example, users can filter photos that were taken at the Eiffel Tower. Click here to download the source files including the javascript and php used to create the product.
Authentication

The first thing we need is an access token. Instagram uses OAuth 2.0 protocol for simple, but effective authentication. I could tell you how to retrieve access tokens but then I'd have to kill you (And everything I've done is documented on Instagram's Developer page). Instead, to make your lives easier, I've provided an easy way for you to attain your access token and user id. Click here to retrieve your access token and user ID.

Instagram has a 5000 request per hour rate limit. This is high in comparison to twitter and similar services so bundling requests to avoid the hitting the limit may not be necessary unless you have high volumes of traffic.
Retrieve Images

Now we are ready to get our images. See the code below to make this happen. In our example, we are using PHP's CURL library to make our requests.

<?php
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$result = fetchData("https://api.instagram.com/v1/users/ID-GOES-HERE/media/recent/?access_token=TOKEN-GOES-HERE");
$result = json_decode($result);
foreach ($result->data as $post) {
// Do something with this data.
}
?>


The Final Product

This uses my Instagram account. As you can see, I pretty much never use it. Click on one of the images below to see the Fancybox integration. Click here to download the source files including the javascript and php used to create the product.

Culled from https://blueprintinteractive.com/blog/how-instagram-api-fancybox-simplified

(1) (Reply)

Professional Web Development Course / Are A Specialist In Social Media? / Notice For Those That Have Passion For Programming

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.