Created
March 21, 2015 18:35
-
-
Save joeyz/3ec897da3ecdd08a723a to your computer and use it in GitHub Desktop.
json to php object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment