Possible to pull Insights data via Instagram API?

那年仲夏 提交于 2019-12-09 06:49:30

问题


Instagram recently allowed accounts to link to a Facebook Business Page. They also added a new 'Insights' section that gives metrics like:

Impressions Reach Top Posts Followers by Age

I can't find a way to pull these new numbers in via the API. Is there a separate Analytics API that I need to apply for?


回答1:


Quick update for this question: the Instagram Platform API now offers an endpoint for insights.

Endpoint

GET graph.facebook.com
    /{media_id}/insights?metric={engagement|impressions|reach|saved|video_views}

Example

GET graph.facebook.com
    /17895695668004550/insights?metric=impressions,reach

Example Response

{
  "data": [
    {
      "name": "impressions",
      "period": "lifetime",
      "values": [
        {
          "value": 264
        }
      ],
      "title": "Impressions",
      "description": "Total number of times the media object has been seen",
      "id": "17855590849148465/insights/impressions/lifetime"
    },
    {
      "name": "reach",
      "period": "lifetime",
      "values": [
        {
          "value": 103
        }
      ],
      "title": "Reach",
      "description": "Total number of unique accounts that have seen the media object",
      "id": "17855590849148465/insights/reach/lifetime"
    }
  ]
}



回答2:


Having faced this very problem (analytics being confined to the mobile app), I decided to use the Android app SSL Packet Capture (NO root required) to capture the requests (you must manually fetch a post's insights in the app whilst recording). The correct GET request will be listed inside one of the Instagram entries and it's long!

The necessary access token is already embedded in the request and the instagram post id can be substituted to fetch post-level analytics: Reach, Impressions & Engagement. Moreover the GET request must be made over https.

The request (in URL decoded form) will look something like this:

https://graph.facebook.com/graphql?access_token=<ACCESS_TOKEN>&query_id=<QUERY_ID>&locale=en_US&strip_nulls=true&strip_defaults=true&querparams={"0":{"id":"<POST_ID>", "access_token":"<ACCESS_TOKEN_2>:{"_token_ver":2,"_auth_user_id":<USER_ID>,"_token":"<TOKEN>","asns":{"<ASNS>,"time":1476466064},"_auth_user_backend":"accounts.backends.CaseInsensitiveModelBackend","last_refreshed":1476396104.372065,"_platform":1,"_auth_user_hash":""}"}}'


来源:https://stackoverflow.com/questions/38707910/possible-to-pull-insights-data-via-instagram-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!