【问题标题】:How can I manage my Instagram account from Python?如何从 Python 管理我的 Instagram 帐户?
【发布时间】:2014-08-31 11:34:33
【问题描述】:
我正在尝试编写一个 Python 程序,以根据他们在帖子中使用的标签来关注一些用户。我知道 Python 的 instagram 包,但有一些我不明白的地方。
我需要一个令牌来编写这个程序吗?如果是这样,令牌到底是什么?当我运行 get-token 函数时,它要求我编写重定向 URL、请求的范围和“重定向后在查询字符串中粘贴代码:”,我不知道是这样的。
谢谢你,JM
【问题讨论】:
标签:
python
logging
token
instagram
【解决方案1】:
您需要了解OAuth 2 才能了解令牌的真正含义。但本质上,重定向 URL 是 Instagram 在用户批准后将其发送到想要使用您的应用程序的地方。您将需要托管您的应用程序。 (How to do this?)。 Instagram 还有一个页面可以帮助开发者入门here。
完成上述步骤并获得令牌后,您可以执行以下操作,
from instagram.client import InstagramAPI
access_token = "YOUR_ACCESS_TOKEN"
api = InstagramAPI(access_token=access_token)
# Subscribe to all media tagged with 'fox'
api.create_subscription(object='tag', object_id='fox', aspect='media', callback_url='http://example.com/hook/instagram')