php 如何在 Instagram 中获取其他页面关注者的数量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34906301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:17:14  来源:igfitidea点击:

How to get other pages followers count number in Instagram?

phpinstagraminstagram-api

提问by eMKa

is there possibility to get other pages follower count number in Instagram? I can get only my profile followers count number, but I want to get other followers too? (for example in php)

是否有可能在 Instagram 中获得其他页面的粉丝计数?我只能获得我的个人资料关注者计数,但我也想获得其他关注者?(例如在 php 中)

Any ideas?

有任何想法吗?

回答by rNix

Yes, it's possible with ?__a=1queries which return json.

是的,可以使用?__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;
    }
}

回答by NativePaul

Jumping through hoops to get an app approved for quickly checking follower counts seemed excessive so I had a look at network requests on Instagram's web search and saw that typing in the search box fires off requests to this URL:

为了快速检查粉丝数量而获得批准的应用程序似乎有些过分,所以我查看了 Instagram 网络搜索上的网络请求,发现在搜索框中输入会触发对这个 URL 的请求:

https://www.instagram.com/web/search/topsearch/?query={searchquery}

That returns a JSON feed which has a bunch of info on the user including a value for follower_count. If you are logged in, the results are weighted by relevance to your account, but you don't have to be authenticated or even logged in to get a result:

这将返回一个 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": [ ]
}

回答by Gabriel Intriago

Using yahoo query language

使用雅虎查询语言

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

回答by krisrak

you can get any user's followers count but you cant get the user's followers details, you can only get your follower list.

您可以获取任何用户的关注者数量,但无法获取用户的关注者详细信息,您只能获取关注者列表。

This is API to get follower count of any user:

这是获取任何用户的关注者数量的 API:

https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN

https://www.instagram.com/developer/endpoints/users/#get_users

https://www.instagram.com/developer/endpoints/users/#get_users

UPDATE: I noticed that didn't work and I just tried this: https://api.instagram.com/v1/users/self/?access_token=XXXXXand got some good info ... MQ

更新:我注意到这不起作用,我只是尝试了这个:https: //api.instagram.com/v1/users/self/?access_token =XXXXX并得到了一些好的信息...... MQ

回答by km13oj

There are a few analytics tools that allow you to get the follower count without an access token other than your own. If you login to Crowdbabble and add an Instagram account, you will be asked to login to your Instagram account. After that, though, you can add any Instagram account and get the number of followers. This will give you the follower list, most engaging followers, and most influential followers for any account.

有一些分析工具可以让你在没有访问令牌的情况下获得关注者数量,而不是你自己的。如果您登录 Crowdbabble 并添加 Instagram 帐户,系统会要求您登录您的 Instagram 帐户。不过,在那之后,您可以添加任何 Instagram 帐户并获取关注者的数量。这将为您提供任何帐户的关注者列表、最具吸引力的关注者和最具影响力的关注者。

If you apply for the Instagram API (now requires a written application and a video submission), you can set up an app like this yourself. You can make calls to different accounts using just one access token.

如果你申请了 Instagram API(现在需要书面申请和视频提交),你可以自己设置一个这样的应用程序。您只需使用一个访问令牌即可调用不同的帐户。

回答by Harsha

I've used yahoo API, in my case I figured out like this,

我用过雅虎 API,就我而言,我是这样想出来的,

hope this helps someone because I've searched a lot for this.

希望这对某人有所帮助,因为我为此搜索了很多。

$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;

anyone know better way get directly with JSON object, without replacing special characters ? please correct me if yes.

有人知道直接使用 JSON 对象而不替换特殊字符的更好方法吗?如果是,请纠正我。