如何在Facebook API上无需手动步骤即可生成访问令牌
我正在尝试制作一个简单的Instagram帖子机器人,我可以在其中提供图像和标题的URL,并且会发布。我目前有一个工作的python脚本,该脚本将从固定的交换令牌(通过Graph API工具网页手动生成)生成长寿令牌,并将发布给定URL的映像。
问题是在一段时间后(不到一天),令牌到期,我必须手动产生另一个。
我可以成功生成应用程序访问令牌,但我不相信您可以使用应用程序访问令牌来发布内容。有没有办法自动生成用户令牌?不用使用Chromedriver之类的东西来模仿令牌生成的浏览器
。
I am trying to make a simple Instagram post bot where I can provide a url of an image and a caption and it will post. I currently have a working python script that, will generate long life token from a fixed exchange token (generated manually at the graph api tool webpage) and will will post an image given a url.
The problem is after a while (Less than a day) the token expires and I have to manually generate another.
I can successfully generate an app access token but I don't believe you can use an app access token for posting content. Is there a way to automatically generate a user token? pref without using something like chromedriver to mimic a browser for the token generation
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我强烈建议您花几分钟阅读 关于访问令牌。
从那里您可以更好地了解不同类型的访问令牌。
继续..请确保您使用正确的端点来获取长期活着的访问令牌(如果您的令牌只需一天即可到期,则意味着您不是)。
使用长期活着的访问访问token 通过Graph API Explorer生成的令牌路径:
App的访问令牌不会让您访问内容出版。
为此,您需要使用上一步生成的用户令牌。
确保用户拥有所有需要的权限:
ads_management,business_management,instagram_basic,instagram_content_publish,pages_read_engagement。
First of all, I strongly recommend you to spend a few minutes reading the References on Access Tokens.
From there you can better understand the different types of Access Tokens.
Moving on.. Make sure you are using the correct endpoint to get that Long Lived Access Token (If your token is taking only a day to expire, means you aren't).
Use the Long Lived Access Token path with the token you generated via Graph API Explorer:
App's Access Token does not give you access to Content Publishing.
For that you need to use your User Token generated on the previous step.
Make sure the User have all the Permissions needed:
ads_management, business_management, instagram_basic, instagram_content_publish, pages_read_engagement.