Checking if a instagram image is private

房东的猫 提交于 2019-12-30 11:39:07

问题


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".



来源:https://stackoverflow.com/questions/13911733/checking-if-a-instagram-image-is-private

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