谁分享我的Facebook帖子? [英] Who shared my Facebook post?

查看:171
本文介绍了谁分享我的Facebook帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用任何Facebook API for Python,我试图让分享我的帖子的人数和这些人是谁。我目前有第一部分。

Using any Facebook API for Python, I am trying to get the # of people who shared my post and who those people are. I currently have the first part..

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

得到计数,但是想要知道这些人是谁。

That gets the count, but I want to know who those people are.

推荐答案

sharedposts 给你更多关于一个职位股份的信息。您必须 GET USER_ID?fields = sharedposts 。此信息不会显示在文档中。

The sharedposts connection will give you more information about the shares of a post. You have to GET USER_ID?fields=sharedposts. This information doesn't appear in the doc.

这遵循你的代码:

# 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中,代码中可能会出现一些语法错误。但是你得到了这个想法。

It is my first time with Python, there might be some syntax errors in the code. But you got the idea.

这篇关于谁分享我的Facebook帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆