简体   繁体   中英

Get instagram user analytics by username

I want to get the instagram user analytics, ie to get the time sheet with count of followers and followings. Is there any way to get the data from instagram api? Or Is there other sites that I can get the analytics automatically with PHP?

No analytics API from Instagram yet. we have to search users by user id.

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

In the api response the user json contains "counts" for followers, following and medias.

If you just has usernames with you then first search the users from user name by https://www.instagram.com/developer/endpoints/users/#get_users_search ; get ids from them and use above API.

To generate the trend; we have to make the API calls daily, for all users! very costly, but there is no direct API available from Insta yet.

However, FB just released new API for user insights under graph api.

https://developers.facebook.com/docs/instagram-api/reference/user#insights this works only for instagram business accounts though. and you need the access tokens on behalf of the account you want insights for.

As of 2019-06 you can only access analytics (they call it insights at FB) for your own profile. You can't access insights of other user profile.

For example, let's get your own followers_count .

graph.facebook.com
  /{your_facebookPage_id}/insights?metric=followers_count&period=day

You get this JSON as response:

{
  "insights": {
    "data": [
      {
        "name": "follower_count",
        "period": "day",
        "values": [
          {
            "value": 2,
            "end_time": "2019-06-24T07:00:00+0000"
          },
          {
            "value": 0,
            "end_time": "2019-06-25T07:00:00+0000"
          }
        ],
        "title": "Follower Count",
        "description": "Total number of unique accounts following this profile",
        "id": "{your_facebookPage_id}/insights/follower_count/day"
      }
    ],
    "paging": {
      "previous": "https://graph.facebook.com/v3.3/{your_facebookPage_id}/insights?access_token=...&pretty=0&metric=follower_count&period=day&since=1561115213&until=1561288013",
      "next": "https://graph.facebook.com/v3.3/{your_facebookPage_id}/insights?access_token=...&pretty=0&metric=follower_count&period=day&since=1561460815&until=1561633615"
    }
  },
  "id": "{your_facebookPage_id}"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM