Find out whether a user has a public or private profile on instagram using API?

亡梦爱人 提交于 2019-11-29 10:28:30

Use the GET relationship endpoint.

https://api.instagram.com/v1/users/user-id/relationship

This endpoint returns a BOOL value "target_user_is_private".

You can use the User Media endpoint with client_id:

https://api.instagram.com/v1/users/USER_ID/media/recent/?client_id=YOUR-CLIENT_ID

If the user is private you will get a response like this:

{"meta":{"error_type":"APINotAllowedError","code":400,"error_message":"you cannot view this resource"}}

If the user is public, then you will get API response with "code":200 with user recent media data - "data":[...]

Emily

If you click to unfollow them and it tells you,

"If you change your mind, you'll have to request ____ again."

then they are private and if it says,

"unfollow ____" then they are not.

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