显示用户';网站上的Instagram照片


Show User's Instagram Photos on website

我正试图在我的网站上显示我的最新照片。我曾经在以前版本的Instagram API上做过,但现在它改变了,我不能了。

我在Instagram账户上创建了一个应用程序,并按照文档中的描述完成了所有验证步骤,但它总是向我显示一个要求用户登录的屏幕。但是,即使用户没有登录,我也需要显示图片,在这个新的API版本中可能吗?

PS。我在服务器端使用PHP。

谢谢。

您可以通过用户的身份验证获得用户的所有instagram帖子。没有身份验证,您就无法在新的api系统中使用用户的数据。在新的api中,您可以获取他的帖子图片url并将其保存在数据库中。然后你可以通过这些网址显示图片。

<?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.
  }
?>