How to use Instagram graphql?

﹥>﹥吖頭↗ 提交于 2019-12-21 02:46:12

问题


I'm using the following query https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={acountId}&first=1000&after={cursor} to get an user followers. The information I need is the followed_by_count index that's only available per user on https://www.instagram.com/{username}?__a=1

Is there a query_id that includes the followed_by_count in the result?


回答1:


This query_id code https://www.instagram.com/graphql/query/?query_id=17851374694183129&id=<user_id>&first=1000&after=<end_cursor> is designed to return ONLY media data it does NOT include user profile data.

The simplest solution is to use what IG uses on initial page requests:

https://www.instagram.com/<ig_username>/?__a=1

Here is my RubyOnRails setup:

profile = JSON.parse(open("https://www.instagram.com/<ig_username>/?__a=1").read)

... now grab your variables:

profile.['graphql']['user']['profile_pic_url']

profile.['graphql']['user']['biography']

profile.['graphql']['user']['external_url']

profile.['graphql']['user']['edge_followed_by']['count']

profile.['graphql']['user']['edge_follow']['count']

profile.['graphql']['user']['id']

profile.['graphql']['user']['edge_owner_to_timeline_media']['count']

profile.['graphql']['user']['profile_pic_url']

profile.['graphql']['user']['profile_pic_url_hd']

And your followed_by_count is now ['graphql']['user']['edge_followed_by']['count']



来源:https://stackoverflow.com/questions/45787021/how-to-use-instagram-graphql

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