Python 谁分享了我的Facebook帖子?

Python 谁分享了我的Facebook帖子?,python,facebook,facebook-graph-api,Python,Facebook,Facebook Graph Api,使用任何一个针对Python的Facebook API,我都试图了解分享我帖子的人以及他们是谁。我现在有第一部分 >>> from facepy import * >>> graph = GraphAPI("CAAEr") >>> g = graph.get('apple/posts?limit=20') >>> g['data'][10]['shares'] 这就是总数,但我想知道这些人是谁。共享帖子连接将为您提供有关帖

使用任何一个针对Python的Facebook API,我都试图了解分享我帖子的人以及他们是谁。我现在有第一部分

>>> from facepy import *
>>> graph = GraphAPI("CAAEr")
>>> g = graph.get('apple/posts?limit=20')
>>> g['data'][10]['shares']

这就是总数,但我想知道这些人是谁。

共享帖子连接将为您提供有关帖子共享的更多信息。您必须
获取
用户ID?字段=sharedposts
。此信息不会出现在文档中

以下是您的代码:

# Going through each of your posts one by one
for post in g['data']:

    # Getting post ID
    id = post['id']   # Gives USERID_POSTID
    id[-17:]          # We know that a post ID is represented by 17 numerals

    # Another Graph request to get the shared posts
    shares = graph.get(id + '?fields=sharedposts')  

    print('Post' id, 'was shared by:')

    # Displays the name of each sharer
    print share['from']['name'] for share in shares['data']

这是我第一次使用Python,代码中可能有一些语法错误。但是你有了主意。

Bruckwert谢谢,你的思路是对的。经过一点操作,我得到了它。再次感谢