Checking if a instagram image is private

2019-02-20 16:28发布

问题:

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?

I need this since I have a bunch of Instagram images that I show on my page, but I want to remove the link to them if they become private.

回答1:

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
}


回答2:

Use the GET relationship endpoint.

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

This endpoint returns a BOOL value "target_user_is_private".