I am using this api to get instagram feed on website and getting data but unable to get images.

function fetchData($url){

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

url_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/self/media/recent/?access_token=my_access_token&count=8");

$result = json_decode($result);

foreach ($result->data as $post) {

       if($post->caption->text) {

    echo '<a  target="blank" href="'.$post->link.'" title="'.$post->caption->text.'">

    <img src="'.$post->images->low_resolution->url.'" alt="'.$post->caption->text.'"/>

    </a>';
 }  

}

0 Answers