Instagram API 只返回自己的数据

Instagram API only returning data with self

我正在实施 Instagram API。它仅通过 self 关键字为我自己的用户返回数据。我应该怎么做才能从访问我网站的其他用户那里获取数据。

作品:

https://api.instagram.com/v1/users/self/?access_token=ACCESS_TOKEN

无效

https://api.instagram.com/v1/users/ABC_USER/?access_token=ACCESS_TOKEN

我的完整代码是这样的。

$result = fetchData("https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS_TOKEN");
 $result = json_decode($result);
  print_r($result);

function fetchData($url){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
  $result = curl_exec($ch);
  if(curl_error($ch))
{
echo curl_error($ch);
}
return $result;
curl_close($ch);
}

{user-id} 应该是 id,而不是 username

通常是一个数字,试试这个,它会起作用:

https://api.instagram.com/v1/users/3/?access_token=ACCESS_TOKEN

(如果你想为用户名查找user-id,使用用户搜索API搜索用户名,然后获取用户id,然后在上面使用它API)