【发布时间】:2021-10-04 01:48:56
【问题描述】:
我正在尝试制作一个简单的 python 脚本,它使用请求将文本消息发布到 facebook 页面。
我实际上成功地完成了这个壮举,但是,当我将相同的逻辑添加到我的一个更大的项目中时,某个请求会返回一个不同的 json。
根据此页面https://developers.facebook.com/docs/pages/access-tokens,我可以将我在图形浏览器工具中生成的短期用户令牌交换为持续 60 天的长期用户令牌。到目前为止,这对我有用。当我在另一个包含其他逻辑的 .py 文件上运行相同的函数时,相同的变量也不会返回此行:
“expires_in”:SECONDS-UNTIL-TOKEN-EXPIRES
当然,稍后如果我继续逻辑并使用它返回的令牌(相同)用于请求打印的 make_post 函数
{'error': {'message': '(#200) If posting to a group, requires app being installed in the group, and \\\n either publish_to_groups permission with user token, or both manage_pages \\\n and publish_pages permission with page token; If posting to a page, \\\n requires both manage_pages and publish_pages as an admin with \\\n sufficient administrative permission', 'type': 'OAuthException', 'code': 200, 'fbtrace_id': 'AqYMMeOcOniWAGgEEtsEURs'}
为什么没有成功返回,用户token没有过期,并且拥有required权限。此外,我在一个较小的 .py 文件中对此进行了测试,并且可以正常工作。
我在这里https://developers.facebook.com/support/bugs/523165725596520/?join_id=f1ff8392b49675c 发现的另一件事是,其他人实际上报告了同样的问题,但它已被“按设计意图”关闭,但没有解决方案的信息。
在我的浏览器中运行请求也无法正常工作。
你有什么想法吗?我完全一无所知。 提前非常感谢您
【问题讨论】:
-
错误报告唯一提到的是,当令牌没有任何默认到期时,您不会得到
expires_in返回。只要你还有一个令牌,这与你引用的错误消息几乎没有关系。
标签: json python-3.x facebook-graph-api python-requests token