Who shared my Facebook post?

facebook, facebook-graph-api, python

Solution

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.

This follows your code:

# 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']

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

Problem

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.

Original source