2013-05-21 121 views
1

我想在我的应用程序页面墙上发表帖子,就好像它来自应用程序页面(而不是另一个用户)研究后,我似乎找不到解决方案,实际上作品!发布到Facebook应用程序页面墙作为应用程序页在python

我曾试图按照此文件:

然后我通过得到它让我的 'access_token_page':使用Facebook的Python API

https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials 

然后我尝试:

graph1 = facebook.GraphAPI(access_token_page) 
graph1.put_wall_post(fbmessage, attachment, profile_id=APP_PAGE_ID) 

但是,这只是返回以下的Facebook错误:

*** GraphAPIError: (#200) The user hasn't authorized the application to perform this action 

关于我失踪的任何想法?请记住,我期望让应用页面自己发表帖子,而不是从其他用户名生成帖子。

谢谢!

回答

1

你所做的是使用应用程序访问令牌发布到页面。

您应该使用页面访问令牌代替页面管理员发布。 用户访问令牌也可以工作,但这是一个在https://developers.facebook.com/bugs/647340981958249报告的错误,所以在撰写本文时不推荐使用用户访问令牌

如记录在https://developers.facebook.com/docs/reference/api/page/#page_access_tokens:对不同类型的访问令牌

Page Access Tokens

To perform the following operations as a Page, and not the current user, you must use the Page's access token, not the user access token commonly used for reading Graph API objects. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission.

更多信息请访问:https://developers.facebook.com/docs/facebook-login/access-tokens/

1

尝试Django的Facebook的: https://github.com/tschellenbach/Django-facebook 这将解决您的许多API的问题。

您需要的页面访问令牌,在这里看到: https://developers.facebook.com/docs/facebook-login/access-tokens/ 询问manage_pages作为一个额外的许可

获得该设置后,只需做:

user_graph = OpenFacebook(user_access_token) 
response = user_graph.get('me/accounts') 
# turn the response to a dict, and be sure to get the page you want 
page_access_token = response['data'][0]['access_token'] 
graph = OpenFacebook(page_access_token) 
graph.set('me/feed', message='helloworld') 

你可以在这里找到更多的文档:

http://django-facebook.readthedocs.org/en/latest/open_facebook/api.html

相关问题