java关注列表_如何从一个Instagram帐户中获取关注者列表?

您的client_id可能处于沙盒模式 . 您无法从白名单以外的帐户获取信息 . 如果您向应用程序发送评论,则可以退出沙盒模式 .

但是有一个更简单的解决方案 . 您只需拨打一个电话即可从网络版(无需API)获取公开信息:

$otherPage = 'nasa';

$response = file_get_contents("https://www.instagram.com/$otherPage/?__a=1");

if ($response !== false) {

$data = json_decode($response, true);

if ($data !== null) {

$follows = $data['user']['follows']['count'];

$followedBy = $data['user']['followed_by']['count'];

echo $follows . ' and ' . $followedBy;

}

}

Update. 对不起,我误解了你的问题 . 可以在没有API的情况下获取列表 . 您需要cookie中的csrf令牌和用户ID,然后调用查询:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://www.instagram.com/query/");

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

//You need the csrftoken, ds_user_id

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: ..."));

curl_setopt($ch, CURLOPT_POST, 1);

$userId = 528817151;

curl_setopt($ch, CURLOPT_POSTFIELDS,

"q=ig_user($userId) {

followed_by.first(10) {

count,

page_info {

end_cursor,

has_next_page

},

nodes {

id,

is_verified,

followed_by_viewer,

requested_by_viewer,

full_name,

profile_pic_url,

username

}

}

}");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);

curl_close ($ch);

var_dump($server_output);

您可以在Instagram网站上获取正确的cookie进行登录操作 .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值