我在Facebook和我的个人资料中创建应用程序。在“选择你的应用如何与Facebook集成”部分,我不选择任何选项,因为我只想将文本发布到Facebook页面(也许这是问题?)。 我有这样的代码:如何获取页面访问令牌
FACEBOOK_APP_ID = 'myappid'
FACEBOOK_APP_SECRET = 'myappsecret'
FACEBOOK_PROFILE_ID = 'myprofileid'
oauth_args = dict(client_id = FACEBOOK_APP_ID,
client_secret = FACEBOOK_APP_SECRET,
scope = 'publish_stream',
grant_type = 'client_credentials'
)
oauth_response = urllib.urlopen('https://graph.facebook.com/oauth/access_token?' + urllib.urlencode(oauth_args)).read()
oauth_response看起来不错
但是当我运行:
resp = urllib.urlopen('https://graph.facebook.com/me/accounts?'+oauth_response).read()
我得到错误:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
我在做什么错?我想在页面墙上张贴一些文字,例如,我点击我网站上的按钮(Django)。
更新:
好的,我在json中获取页面数据。我分析它,我得到page_access_token,但是当我把这个:
attach = {
"name": 'Hello world',
"link": 'http://linktosite',
"caption": 'test post',
"description": 'some test'
}
facebook_graph = facebook.GraphAPI(page_access_token)
try:
response = facebook_graph.put_wall_post('', attachment=attach)
except facebook.GraphAPIError as e:
print e
我得到的错误:“我们的目标用户没有授权这个动作”