可以获取其他用户的媒体吗? Instgram API

问题描述 投票:0回答:1

我从另一个网络上获取的这段代码可以工作!但只有当我输入我的 Instagram ID 时。否则,当我想从另一个用户那里获取媒体(更改变量

userid
)时,它会停止工作。

为了确保我使用 https://www.otzberg.net/iguserid/index.php 来获取用户 ID。 并获取访问令牌(仅限我的帐户):http://instagram.pixelunion.net/

<?php
    // Supply a user id and an access token
    $userid = "-----";
    $accessToken = "---";

    // Gets our data
    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;
    }
    // Pulls and parses data.
    $result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}");
    $result = json_decode($result);
    ?>
<?php if(!empty($result->data)): ?>
    <?php foreach ($result->data as $post): ?>
        <!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
        <a class="group" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
    <?php endforeach ?>
<?php endif ?>
php instagram-api
1个回答
0
投票

您发布的链接清楚地表明该令牌仅适用于您自己的图像。

为了在您的自己的网站上显示您的 Instagram 照片, 您需要提供 Instagram 访问令牌。

您应该尝试不同的 API 或方法来显示其他用户的图像。

© www.soinside.com 2019 - 2024. All rights reserved.