<?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/417308232/media/recent/?access_token=417308232.ab103e5.853f4afd42c943e2aa238c6d40604cb0"); $result = json_decode($result); foreach ($result->data as $post) { // Do something with this data. } ?>