Checking if a instagram image is private

后端 未结 2 909
被撕碎了的回忆
被撕碎了的回忆 2021-01-15 21:06

Say I have the URL to an image, http://instagr.am/p/xxxxxxxx/, how can I check if the image is set to private or not from a webpage? Is there some API that I can use?

<
相关标签:
2条回答
  • 2021-01-15 21:21

    I did not find a way to see if a specific image was private or not, so instead i save the AuthorID of the image. If this author has a private profile i will get an exception when trying to get the user information, and if i get an exception, then i know i can remove the link to the image.

    This is my powershell-code i use:

    try
    {
        Invoke-WebRequest "https://api.instagram.com/v1/users/<InsertAuthorID>/?client_id=xxxx";
    }
    catch [Exception]
    {
        # Remove Image
    }
    
    0 讨论(0)
  • 2021-01-15 21:34

    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)
提交回复
热议问题