Information of re-shared status

后端 未结 3 1483
后悔当初
后悔当初 2021-02-02 04:49

I am working with Facebook graph api for few days. I am trying to extract user\'s status and the information of reshared if any. I can easily find status of a user using

相关标签:
3条回答
  • 2021-02-02 05:11

    The sharedposts field applies to a status id. For example, the status id 10151794781777494 is from a status update by the TheKrazyCouponLady which has been shared 4 times. This query:

    /10151794781777494?fields=sharedposts
    

    Will return all the information about the users that have shared it. If you want to limit the returned fields to the name and id of the sharer, and the time and location it was shared, you could do this:

    /10151794781777494?fields=sharedposts.fields(from,created_time,place)
    

    Although I expect there won't be any location data most of the time.

    To find the status id in the first place, you could just query the statuses field for a particular user. Again, using TheKrazyCouponLady (uid 255919387493) as an example:

    /255919387493?fields=statuses
    

    To get just the ids:

    /255919387493?fields=statuses.fields(id)
    

    As an alternative to that, you may want to consider querying the user's posts instead. The advantage to using posts, is that you can get back the share count for each post in that query.

    /255919387493?fields=posts.fields(id,shares)
    

    If the share count on a post is zero, then there is obviously no need to run another query to retrieve the users that have shared that post.

    The downside of using posts is that the post id is slightly different from a status id. You'll see ids that look like this:

    255919387493_10151794781777494
    

    The first half of that string is the user id of the post owner. The second half is the actual status id. If you want to query the sharedposts field for the post, you first have to extract the second half (the status id) and use that for the query.

    Having said that, it occurs to me that you could actually retrieve all the information you need in one go if you chain the statuses query and the sharedposts query together. For example, something like this:

    /255919387493?fields=statuses.fields(id,message,sharedposts.fields(from,created_time,place))
    

    That will return the status id and message text for each status from that user, and the user details, create time and location for each person that shared each of those statuses.

    Even with paging, though, that is likely to be a fairly slow query, so I'm not sure if that's such a good idea. It's worth considering though.

    0 讨论(0)
  • 2021-02-02 05:11

    According new version of API 2.1 and documentation from here https://developers.facebook.com/docs/graph-api/reference/v2.1/post there is a new edge called "sharedposts"

    As described here https://developers.facebook.com/docs/graph-api/reference/v2.1/object/sharedposts

    This reference describes the /sharedposts edge that is common to multiple Graph API nodes. The structure and operations are the same for each node.

    This edge represents any posts where the original object was shared on Facebook.

    0 讨论(0)
  • 2021-02-02 05:35

    If the post type is photo sharedposts will return empty as the object is different to the postID

    /317380948302131_847979698575584                  => Object : 847979378575616
    
    /317380948302131_847979698575584/sharedposts?fields=from,via  
    

    ObjectID will work as expected

    /847979378575616//sharedposts?fields=from,via   
    

    The only problem if the object is a shared_post it will show all shares from the original post object too and no via node is present . Just struggle around some time why the APi only sometimes return sharedposts

    0 讨论(0)
提交回复
热议问题