python - 谁分享了我的 Facebook 帖子?

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

这就够了,但我想知道那些人是谁。

最佳答案

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,代码中可能存在一些语法错误。但是你明白了。

关于python - 谁分享了我的 Facebook 帖子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17412772/

相关文章:

android - facebook 权限, session : an attempt was made to request new permissions for a session that has a pending request

python - 从 numpy 数组创建图形顶点

Python 等价于 Haskell 的 [1..](索引列表)

facebook - 我的 friend 无法查看通过我的开放图谱应用程序发布的帖子,但我可以

facebook - 您将 Facebook 上的域列入白名单以进行视频嵌入吗?

android - 从 facebook 墙到 android 应用程序的新闻提要

android - Facebook 深层链接始终打开 Google Play 商店

python - 如何在 Wampserver 上设置和运行 Python?

python - 如何修改解析器计算器语法以继续对先前结果进行计算?

facebook - 什么是 fbclid?新的 facebook 参数