谁分享了我的Facebook帖子?

时间:2013-07-01 20:07:32

标签: 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']

这是重要的,但我想知道这些人是谁。

1 个答案:

答案 0 :(得分:5)

sharedposts连接将为您提供有关帖子共享的更多信息。您必须GET USER_ID?fields=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,代码中可能存在一些语法错误。但你明白了。

相关问题