如何在不通过用户身份验证的情况下从Instagram获取用户的媒体? [英] How can I get a user's media from Instagram without authenticating as a user?
问题描述
我正在尝试将用户最近的Instagram媒体放在侧边栏上.我正在尝试使用Instagram API来获取媒体.
I'm trying to put a user's recent Instagram media on a sidebar. I'm trying to use the Instagram API to fetch the media.
http://instagram.com/developer/endpoints/users/
该文档对GET https://api.instagram.com/v1/users/<user-id>/media/recent/
说,但是它说要传递OAuth访问令牌.访问令牌表示代表用户执行操作的授权.我不希望用户登录Instagram在侧栏上看到它.他们甚至不需要拥有Instagram帐户.
The documentation says to GET https://api.instagram.com/v1/users/<user-id>/media/recent/
, but it says to pass an OAuth access token. An access token represents the authorization to act on behalf of a user. I don't want users to log into Instagram to see this on the sidebar. They shouldn't even need to have an Instagram account.
例如,我无需登录Instagram即可访问 http://instagram.com/thebrainscoop 看照片.我想通过API做到这一点.
For instance, I can go to http://instagram.com/thebrainscoop without being logged into Instagram and see photos. I want to do that through the API.
在Instagram API中,未经用户身份验证的请求将传递client_id
而不是access_token
.但是,如果尝试这样做,我会得到:
In the Instagram API, non-user-authenticated requests pass a client_id
instead of an access_token
. If I try that, though, I get:
{
"meta":{
"error_type":"OAuthParameterException",
"code":400,
"error_message":"\"access_token\" URL parameter missing. This OAuth request requires an \"access_token\" URL parameter."
}
}
那么,这不可能吗?在没有要求用户先通过OAuth登录Instagram帐户的情况下,是否无法获取用户的最新(公共)媒体?
So, is this not possible? Is there no way to fetch a user's latest (public) media without asking a user to log into an Instagram account through OAuth first?
推荐答案
这已经很晚了,但是如果它可以帮助某人,那是值得的,因为我在Instagram文档中没有看到它.
This is late, but worthwhile if it helps someone as I did not see it in Instagram's documentation.
要在https://api.instagram.com/v1/users/<user-id>/media/recent/
上执行GET(在撰写本文时),您实际上不需要OAuth访问令牌.
To perform GET on https://api.instagram.com/v1/users/<user-id>/media/recent/
(at present time of writing) you actually do not need OAuth access token.
您可以执行https://api.instagram.com/v1/users/[USER ID]/media/recent/?client_id=[CLIENT ID]
[客户端ID]将是通过管理客户端在应用中注册的有效客户端ID(与用户无关).
您可以通过执行GET用户搜索请求从用户名中获取[USER ID]:
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
[CLIENT ID] would be valid client id registered in app through manage clients (not related to user whatsoever).
You can get [USER ID] from username by performing GET users search request:
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
这篇关于如何在不通过用户身份验证的情况下从Instagram获取用户的媒体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!