【发布时间】:2016-04-26 16:02:23
【问题描述】:
是否有可能在 Instagram 中获得其他页面的关注者计数? 我只能获得我的个人资料关注者计数,但我也想获得其他关注者? (例如在 php 中)
有什么想法吗?
【问题讨论】:
标签: php instagram instagram-api
是否有可能在 Instagram 中获得其他页面的关注者计数? 我只能获得我的个人资料关注者计数,但我也想获得其他关注者? (例如在 php 中)
有什么想法吗?
【问题讨论】:
标签: php instagram instagram-api
是的,?__a=1 查询返回 json 是可能的。
$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['graphql']['user']['edge_follow']['count'];
$followedBy = $data['graphql']['user']['edge_followed_by']['count'];
echo $follows . ' and ' . $followedBy;
}
}
【讨论】:
为了快速检查关注者数量而获得批准的应用程序似乎太过分了,所以我查看了 Instagram 网络搜索中的网络请求,发现在搜索框中输入会触发对该 URL 的请求:
https://www.instagram.com/web/search/topsearch/?query={searchquery}
这会返回一个 JSON 提要,其中包含有关用户的大量信息,包括 follower_count 的值。如果您已登录,则结果会根据与您帐户的相关性进行加权,但您无需经过身份验证甚至登录即可获得结果:
{
"has_more": false,
"status": "ok",
"hashtags": [],
"users": [
{
"position": 0,
"user": {
"username": "thenativepaul",
"has_anonymous_profile_picture": false,
"byline": "457 followers",
"mutual_followers_count": 0.0,
"profile_pic_url": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-19/11373838_482400848607323_1803683048_a.jpg",
"full_name": "Paul Almeida-Seele",
"follower_count": 457,
"pk": 21072296,
"is_verified": false,
"is_private": false
}
},
{
"position": 1,
"user": {
"username": "the_native_warrior",
"has_anonymous_profile_picture": false,
"byline": "251 followers",
"mutual_followers_count": 0.0,
"profile_pic_url": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-19/s150x150/14473927_312669442422199_4605888521247391744_a.jpg",
"profile_pic_id": "1352745514521408299_1824600282",
"full_name": "Paul Carpenter",
"follower_count": 251,
"pk": 1824600282,
"is_verified": false,
"is_private": true
}
}
],
"places": [ ]
}
【讨论】:
使用雅虎查询语言
https://query.yahooapis.com/v1/public/yql?q=select * from html where url='https://www.instagram.com/USERNAME/' and xpath='/html/body/script[1]'&format=json
【讨论】:
Redirected to a robots.txt restricted URL
您可以获取任何用户的关注者数量,但您无法获取用户的关注者详细信息,您只能获取您的关注者列表。
这是获取任何用户的关注者数量的 API:
https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN
https://www.instagram.com/developer/endpoints/users/#get_users
更新:我注意到这不起作用,我只是尝试了这个:https://api.instagram.com/v1/users/self/?access_token=XXXXX 并得到了一些很好的信息...... MQ
【讨论】:
有一些分析工具可让您获得关注者数量,而无需您自己的访问令牌。如果您登录 Crowdbabble 并添加 Instagram 帐户,您将被要求登录您的 Instagram 帐户。不过,在那之后,您可以添加任何 Instagram 帐户并获取关注者的数量。这将为您提供任何帐户的关注者列表、最吸引人的关注者和最有影响力的关注者。
如果您申请 Instagram API(现在需要书面申请和视频提交),您可以自己设置这样的应用程序。您可以只使用一个访问令牌来调用不同的帐户。
【讨论】:
我使用过 yahoo API,就我而言,我是这样想的,
希望这对某人有所帮助,因为我已经为此搜索了很多。
$url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url=%27https://www.instagram.com/USERNAME/%27%20and%20xpath=%27/html/body/script[1]%27&format=json";
$json = file_get_contents($url);
$obj = json_decode($json, true);
$content = $obj['query']['results']['script']['content'];
$content = str_replace("window._sharedData =", "", $content);
$content = str_replace(";", "", $content);
$content = trim($content);
$json = json_decode($content);
$instagram_follower_count = $json->entry_data->ProfilePage{0}->user->followed_by->count;
谁知道直接使用 JSON 对象而不替换特殊字符的更好方法?如果是,请纠正我。
【讨论】:
Redirected to a robots.txt restricted URL 我收到了来自 insta 的消息!