I was downloading all the posts of public pages. For example a recent post from 'Google's page in facebook looks like this :
{
"created_time": "2016-02-04T02:55:11+0000",
"message": "We hope you\u2019re just as excited about the Year of the Monkey as we are! So excited, we\u2019ve been hunting around Street View for monkey sightings. Here are a few we found so far...want to help us find more 'Monkeys of StreetView'? #monkeyview goo.gl/8LhqMe",
"story": "Google added 4 new photos to the album: Monkeys of StreetView.",
"id": "104958162837_10153902425172838"
}
This json object is one of the posts returned by the following code: (The code is from other stack-overflow page but there are limitations to post links)
from facepy import GraphAPI
import json
page_id = "Google"
access_token = "AccessToken"
graph = GraphAPI(access_token)
data = graph.get(page_id + "/feed", page=False, retry=3, limit=100)
with open('content.json', 'w') as outfile:
json.dump(data, outfile, indent = 4)
This post is supposed to have more fields. For example using the id associated with this post I use this link and see there are other fields. For example there are multiple pictures in this post and 'https://graph.facebook.com/v2.4/104958162837_10153902425172838?fields=picture&access_token=AccessToken' will return :
{ "picture": "https://scontent.xx.fbcdn.net/hphotos-xfa1/v/t1.0-0/s130x130/12654459_10153902425172838_781196554188881203_n.jpg?oh=eef2aa5a6297767d9bd924c1e3311afc&oe=576EC3CA", "id": "104958162837_10153902425172838" }
Similarly it has other fields that are not shown in the result of the code. It should for example also show the likes to this post. So I have two questions:
Why the result is not showing all the fields although those fields exist and can be found by querying the id of that post
This post has multiple pictures but we are getting only one of the pictures and when I query for the number of likes and comments instead of returning likes or comments for the post, it return it for a certain picture.
Thank you.
By default, not all the fields in a node or edge are returned when you make a query. You can choose the fields (or edges) you want returned with the "fields" query parameter. This is really useful for making your API calls more efficient and fast.
In your case you could change your call to the following to retrieve (for example) the message and picture fields
graph.get(page_id + "/feed", page=False, retry=3, limit=100, fields="message,picture")
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments