Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 显示Instagram图像_Php_Instagram_Photo_Display - Fatal编程技术网

Php 显示Instagram图像

Php 显示Instagram图像,php,instagram,photo,display,Php,Instagram,Photo,Display,如何在我的网站上显示instagram照片? 我试图使用Instagram的API解决这个问题,但它不能正常工作: $user = file_get_contents( "https://api.instagram.com/v1/users/self/media/recent/?access_token=$access_token" ); $user = json_decode($user, true)['data']; $media = file_get_contents( "https:/

如何在我的网站上显示instagram照片? 我试图使用Instagram的API解决这个问题,但它不能正常工作:

$user = file_get_contents( "https://api.instagram.com/v1/users/self/media/recent/?access_token=$access_token" );
$user = json_decode($user, true)['data'];

$media = file_get_contents( "https://api.instagram.com/v1/users/self/media/recent/?access_token=$access_token&count=5" );
$media = json_decode($media, true)['data'];

print_r($media);

我从回复中看到,您希望在打印
$media
后看到图像,这是一个数组

例如,如果您想单独访问Instgram配置文件中的图像,您应该循环访问从API获取的数据,分别检索每个图像,并轻松访问数组中的URL索引,进入
图像->低分辨率->URL。“”alt=“”.$post->caption->text。“”width=“100%”height=“auto”/>
';
}
}  

这是什么意思-不正确?
打印($media)
向您展示了什么?什么不起作用?是否有任何错误消息,如果有,请将其发布在此处。您是在尝试嵌入某人的整个提要还是仅嵌入一些选定的图片?它只打印文本信息,而不打印图像,我正在尝试嵌入最后5张图片这是我尝试遵循的教程:@AlessandraLuz Glay帮助
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/self/media/recent/?access_token=$access_token");

    $result = json_decode($result);
    foreach ($result->data as $post) {
    if(empty($post->caption->text)) {
    // Do Nothing
    }
    else {
    echo '
        <img src="'.$post->images->low_resolution->url.'" alt="'.$post->caption->text.'" width="100%" height="auto" />
       ';
    }

  }