Instagram 关注者未显示?
Instagram followers are not showing?
我正在使用此代码计算关注者数量!
<?php
$api_key = '------';
$user_id = '------';
$data = @file_get_contents("https://api.instagram.com/v1/users/$user_id/?client_id=$api_key");
$data = json_decode($data, true);
echo '<pre/>';
print_r($data);
echo $data['data']['counts']['followed_by'];
?>
失败是因为您无法使用客户端 ID 访问 API 的该功能。
您需要通过将用户发送到授权 url 来获得 Access Token
。在 Instagram Docs.
中阅读相关信息
之后,您使用之前的 Access Token
向 /users
发出请求。
我正在使用此代码计算关注者数量!
<?php
$api_key = '------';
$user_id = '------';
$data = @file_get_contents("https://api.instagram.com/v1/users/$user_id/?client_id=$api_key");
$data = json_decode($data, true);
echo '<pre/>';
print_r($data);
echo $data['data']['counts']['followed_by'];
?>
失败是因为您无法使用客户端 ID 访问 API 的该功能。
您需要通过将用户发送到授权 url 来获得 Access Token
。在 Instagram Docs.
之后,您使用之前的 Access Token
向 /users
发出请求。