在网站上显示用户的Instagram照片

时间:2022-08-21 15:19:12

I'm trying to show my latest photos on my website. I used to do it on previous version of Instagram API, but now that it changed I can't.

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

I created an app on the Instagram Account, and did all authenticate steps as described on the docs, but it always shows me a screen asking for the user login. But I need to show the pictures even the user is not logged, is it possible in this new API version?

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

PS. I'm using PHP on server-side.

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

Thanks.

谢谢。

2 个解决方案

#1


1  

You can get user's all instagram post by his authentication. Without authentication you can not user's data in new api system. In new api , you can get his post image url and save it in your database. Then you can show image by those url.

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

#2


1  

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

source

资源

#1


1  

You can get user's all instagram post by his authentication. Without authentication you can not user's data in new api system. In new api , you can get his post image url and save it in your database. Then you can show image by those url.

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

#2


1  

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

source

资源