【发布时间】:2018-09-11 00:55:05
【问题描述】:
该应用程序是公开的,并且已被授予适当的权限: Display of app permissions
我的登录用户是该应用的管理员:Display of user permissions
代码如下:
import facebook
import warnings
# Hide deprecation warnings. The facebook module isn't that up-to-date (facebook.GraphAPIError).
warnings.filterwarnings('ignore', category=DeprecationWarning)
# Parameters of your app and the id of the profile you want to mess with.
FACEBOOK_APP_ID = 'SECRET'
FACEBOOK_APP_SECRET = 'SECRET'
FACEBOOK_PROFILE_ID = 'SECRET'
fb_api=facebook.GraphAPI()
api_token=fb_api.get_app_access_token(app_id=FACEBOOK_APP_ID, app_secret=FACEBOOK_APP_SECRET, offline=True)
graph = facebook.GraphAPI(api_token)
# Try to post something on the wall.
try:
fb_response = graph.put_object(parent_object=FACEBOOK_PROFILE_ID, connection_name='feed',
message='Hello, world')
print(fb_response)
except facebook.GraphAPIError as e:
print('Something went wrong:', e.type, e.message)
此代码失败并显示错误消息: OAuthException (#200) 需要 publish_actions 权限,或 manage_pages 和 publish_pages 作为具有足够管理权限的管理员
在这一点上,我确信我已经遵循了我在任何其他帖子中读到的所有内容。他们为 sdk 提供的文档是 here。
【问题讨论】:
-
get_app_access_token听起来你在这里得到的只是一个应用访问令牌。过去使用应用令牌发帖可能有效,但现在您需要使用用户或页面访问令牌。 -
我将不得不安装 puppeteer 或 selenium,这就像超级跛脚
-
也是不允许的,被抓到时可能会被屏蔽。如果您有合法的用例要发布,为什么不能获得合适的令牌?
-
在宏伟的计划中它是不合法的。但它也不是恶意的或具有广泛影响的。如果推荐人是 facebook,许多网站允许以独特的方式访问它们。但它不仅仅是设置一个引用者,据我所知,它也不在链接参数中。它可能是唯一的密钥或设置在本地存储或某种 cookie 中的东西。这似乎是故意混淆的东西。虽然只需发布到 Facebook,然后点击链接,这应该很容易。应用程序无法做到这一点一定是最近才出现的,因为那里有很多教程。
标签: python facebook api facebook-graph-api