【问题标题】:How to get other pages followers count number in Instagram?如何在 Instagram 中获取其他页面的关注者计数?
【发布时间】:2016-04-26 16:02:23
【问题描述】:

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

有什么想法吗?

【问题讨论】:

    标签: php instagram instagram-api


    【解决方案1】:

    是的,?__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;
        }
    }
    

    【讨论】:

    • 这太棒了,正是我正在寻找的,而无需使用 api!推特有类似的东西吗?
    • 截至 2019 年 8 月,此端点已恢复,并且正在再次工作。
    • 这不起作用。我认为,此 api 已被弃用。它通过重定向到登录页面来询问登录凭据。请立即查看
    • 你是我的英雄....你成就了我的一天,拯救了我的生命,谢谢兄弟 :)
    • "instagram.com/$username/?__a=1" 解决方案有效,但几周后,instagram 阻止了该域,因此系统无法获取关注者计数以显示在我们的网站上。我在 2 个域/网站上遇到了这个问题。
    【解决方案2】:

    为了快速检查关注者数量而获得批准的应用程序似乎太过分了,所以我查看了 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": [ ]
    }
    

    【讨论】:

    • 好像 3-18-2019 这个端点现在只返回 {"message": "Server Error", "status": "fail"} 它在 3-17-2019 上工作
    • 重定向到登录页面需要登录凭证:(
    【解决方案3】:

    使用雅虎查询语言

    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
    

    【讨论】:

    • YQL 不支持 html(或 html 表格)!试试 htmlstring ! + insta 被 yahoobot 阻止 Redirected to a robots.txt restricted URL
    • 大家好,API url 确实不再可用。 URL 和调用方法多年来一直在变化
    【解决方案4】:

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

    这是获取任何用户的关注者数量的 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

    【讨论】:

    • 谢谢 Krisrak,但我已经尝试使用上面的代码来获取其他用户页面关注者,但它不起作用。错误:{"meta":{"error_type":"OAuthAccessTokenException","code":400,"error_message":"提供的 access_token 无效。"}}
    • 就像那里说的,你的 access_token 无效,在这里试试:gramfeed.com/accounts/sandbox
    • 好吧,access_token 仅适用于我的个人资料关注者数量:/ 但不适用于其他人:S 是否需要成为沙盒用户才能获得其他个人资料关注者数量?
    • 将其他用户添加到沙箱,接受后,您可以进行api调用并获取计数
    • 但我想匿名获取该信息。可能吗?例如,我想从这里获取关注者数量(10.7k):instagram.com/marketer.ge
    【解决方案5】:

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

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

    【讨论】:

      【解决方案6】:

      我使用过 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 的消息!
      猜你喜欢
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      • 2014-08-13
      • 2019-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-11
      相关资源
      最近更新 更多