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

后端 未结 2 586
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 07:44

I\'ve done a fair bit of searching on the Instagram API docs and can\'t find a way to determine whether or not a user has a public or protected profile?

This also ha

相关标签:
2条回答
  • 2020-12-19 08:07

    Use the GET relationship endpoint.

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

    This endpoint returns a BOOL value "target_user_is_private".

    0 讨论(0)
  • 2020-12-19 08:14

    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":[...]

    0 讨论(0)
提交回复
热议问题