Skip to content

Instantly share code, notes, and snippets.

@AaronRutley
Last active October 11, 2015 08:56
Show Gist options
  • Save AaronRutley/4441cc1bb46342b18071 to your computer and use it in GitHub Desktop.
Save AaronRutley/4441cc1bb46342b18071 to your computer and use it in GitHub Desktop.
<?php
function ar_ig_get_photos() {
// set end point (json)
$endpoint = "https://api.instagram.com/v1/users/etc-json";
// Initiate curl
$ch = curl_init();
// Set The Response Format to Json
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json'));
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$endpoint);
// Execute
$result=curl_exec($ch);
//echo $result;
$decoded_result = json_decode($result, true);
$photo_feed = $decoded_result['data'];
foreach( $photo_feed as $photo_detail ) {
// get the ID for each image
$ig_id = $photo_detail['id'];
// etc
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment