使用 Google Apps 脚本获取 Instagram API
Getting Instagram API with Google Apps Scripting
我在电子表格中列出了 500 个 Instagram 用户名。我想提取所有 500 个帐户的简介并将其放入电子表格中。我正在使用 Google Apps 脚本。我不知道如何访问 instagram 的 api,我可以在其中访问简介。我查看了其他可以提取 Instagram 帐户简介的网站(例如 http://www.pikore.com/humordailyy),但这些网站仍然没有 API。有什么办法可以得到 API 吗?如果没有,有没有办法让我爬过 HTML 或其他东西来获取生物?谢谢。
如 documentation 中所述,Instagram API 需要身份验证 - 特别是代表用户提出的请求。经过身份验证的请求需要一个 access_token,您可以通过执行以下操作来接收它:
Direct the user to our authorization url.
- If the user is not logged in, they will be asked to log in.
- The user will be asked if they would like to grant your application access to her Instagram data.
The server will redirect the user in one of two ways that you choose:
- Server-side flow
- Implicit flow: This method is less secure, but allows applications without any server component to receive an access_token.
对于适用于没有任何服务器组件的应用程序的隐式身份验证流程,只需按照以下步骤操作:
第一步:引导您的用户获得我们的授权URL
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token
此时,Instagram 向用户显示一个登录屏幕,然后是一个确认屏幕,在该屏幕上他们授予您的应用访问其 Instagram 数据的权限。请注意,您可以提供一个可选的范围参数来请求“基本”权限范围之外的其他权限。
第二步:通过URL片段接收access_token
一旦用户通过身份验证并授权您的应用程序,Instagram 会将他们重定向到您的 redirect_uri,并在 url 片段中使用 access_token。它看起来像这样:
http://your-redirect-uri#access_token=ACCESS-TOKEN
只需从 URL 片段中取出 access_token 即可。如果用户选择不授权您的应用程序,您将收到与显式流程中相同的错误响应。
错误:access_denied
error_reason: user_denied
error_description: 用户拒绝了您的请求
我在电子表格中列出了 500 个 Instagram 用户名。我想提取所有 500 个帐户的简介并将其放入电子表格中。我正在使用 Google Apps 脚本。我不知道如何访问 instagram 的 api,我可以在其中访问简介。我查看了其他可以提取 Instagram 帐户简介的网站(例如 http://www.pikore.com/humordailyy),但这些网站仍然没有 API。有什么办法可以得到 API 吗?如果没有,有没有办法让我爬过 HTML 或其他东西来获取生物?谢谢。
如 documentation 中所述,Instagram API 需要身份验证 - 特别是代表用户提出的请求。经过身份验证的请求需要一个 access_token,您可以通过执行以下操作来接收它:
Direct the user to our authorization url.
- If the user is not logged in, they will be asked to log in.
- The user will be asked if they would like to grant your application access to her Instagram data.
The server will redirect the user in one of two ways that you choose:
- Server-side flow
- Implicit flow: This method is less secure, but allows applications without any server component to receive an access_token.
对于适用于没有任何服务器组件的应用程序的隐式身份验证流程,只需按照以下步骤操作:
第一步:引导您的用户获得我们的授权URL
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token
此时,Instagram 向用户显示一个登录屏幕,然后是一个确认屏幕,在该屏幕上他们授予您的应用访问其 Instagram 数据的权限。请注意,您可以提供一个可选的范围参数来请求“基本”权限范围之外的其他权限。
第二步:通过URL片段接收access_token
一旦用户通过身份验证并授权您的应用程序,Instagram 会将他们重定向到您的 redirect_uri,并在 url 片段中使用 access_token。它看起来像这样:
http://your-redirect-uri#access_token=ACCESS-TOKEN
只需从 URL 片段中取出 access_token 即可。如果用户选择不授权您的应用程序,您将收到与显式流程中相同的错误响应。
错误:access_denied
error_reason: user_denied
error_description: 用户拒绝了您的请求