我正在使用此API在网站上获取instagram feed,并获取数据,但无法获取图像。
函数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);
返回$ 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->数据为$ 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>';
}
}