有可能得到另一个用户的媒体吗? Instagram API
It is possible get the media of another user? Instgram API
我从另一个网站获取的这段代码有效!但只有当我输入我的 Instragram 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 ?>
您发布的 link 清楚地表明令牌仅适用于您自己的图像。
In order to display your Instagram photos on your own website,
you are required to provide an Instagram Access Token.
您应该尝试不同的 API 或方法来显示其他用户的图像。
我从另一个网站获取的这段代码有效!但只有当我输入我的 Instragram 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 ?>
您发布的 link 清楚地表明令牌仅适用于您自己的图像。
In order to display your Instagram photos on your own website, you are required to provide an Instagram Access Token.
您应该尝试不同的 API 或方法来显示其他用户的图像。