我需要什么权限才能阅读发布到Facebook页面的用户的姓名?

问题描述:

我想编写一个Python脚本来读取在我的Facebook页面上写消息的Facebook用户的名字.

I want to write a Python script that reads the names of the Facebook users who wrote a message on my Facebook Page.

我正在使用facebook-sdk Python库.线

I'm using the facebook-sdk Python library. The lines

graph = facebook.GraphAPI(page_access_token)
profile = graph.get_object(profile_id)
posts = graph.get_connections(profile['id'], 'feed')
print(posts['data'][0]['message'])
print(posts['data'][0]['from']['name'])

当我使用通过从Graph API资源管理器中复制而来的短期访问令牌时,工作正常.

work fine when I use a short-lived access token retrieved by just copying it from the Graph API explorer.

但是当我生成永不过期的页面访问令牌时(请阅读

But when I generate a never-expiring page access token (read here), there is an error in the last line where the Python script wants to retrieve the name. (KeyError: 'from')

那我该如何设置正确的权限?访问令牌具有user_about_me, user_posts, read_page_mailboxes, manage_pages, publish_pages, public_profile权限,但仍然无法使用.也许我设置我创建的应用程序来检索新的访问令牌时做错了什么?

So how do i set the right permissions? The access token has user_about_me, user_posts, read_page_mailboxes, manage_pages, publish_pages, public_profile permissions, but it still doesn't work. Maybe I did something wrong setting up the app I created to retrieve a new access token?

或者这毕竟不是权限问题? (请参阅我的上一页问题.)

Or maybe this isn't a permissions issue after all? (See my previous question.)

如果使用的是v2.4或更高版本,则需要指定要手动检索的字段.不幸的是,这并没有记录在您正在使用的项目中:

You need to specify the fields you want to retrieve manually if you're using v2.4 or higher. Unfortunately this is not documented in the project you're using:

posts = graph.get_connections(profile['id'], 'feed', 'fields=id,message,from')

我应该根据 https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook/init.py#L117

should work I guess according to https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook/init.py#L117