Make curl/json work on wordpress
-
<?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/**/media/recent/?access_token=******.*******&count=60"); $result = json_decode($result); foreach ($result->data as $post) { if(empty($post->caption->text)) { // Do Nothing } else { echo '<a class="instagram-unit" target="blank" href="'.$post->link.'"> <img src="'.$post->images->low_resolution->url.'" alt="'.$post->caption->text.'" width="50" height="auto" /> </a>'; } } ?>
I got this bit of code to pull instagram images, it works on some online compiler but i cant make it work on wordpress any idea how?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Make curl/json work on wordpress’ is closed to new replies.