Instagram public 媒体 API

Instagram public media API

Instagram API 政策是否允许使用

https://instagram.com/{user-id}/media/

从 iOS 应用获取最新媒体的端点。我们尝试使用记录

api.instagram.com/v1/users/{user-id}/media/recent

但它需要访问令牌。通过调查 Instagram 网络应用程序,我发现它使用第一个 link 的端点来获取用户数据。

Instagram 网络应用未使用您提供的 link,它正在使用:

GET https://instagram.com/{username}/

并且在脚本标签内的响应中,它设置 Window._sharedData 所有数据,包括用户的媒体:

window._sharedData.entry_data.UserProfile[0].userMedia

我不确定政策,但您可以在不调用 API 的情况下获取和提取此数据。

但是,使用 API 会更容易,也是首选方式。当您要获取一些 public 媒体时,您可以使用固定的 client_id 而不是 access_token 来避免 authentication:

Some API only require the use of a client_id. A client_id simply associates your server, script, or program with a specific application. However, other requests require authentication - specifically requests made on behalf of a user. Authenticated requests require an access_token. These tokens are unique to a user and should be stored securely. Access tokens may expire at any time in the future.

API调用:

api.instagram.com/v1/users/{user-id}/media/recent/?client_id={client_id}

Instagram 用户名不是用户 ID。您可以通过 link 找到用户 ID:http://jelled.com/instagram/lookup-user-id