Facebook Graph API not returning all the fields of a perticular post

Roya Feizi

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:

  1. Why the result is not showing all the fields although those fields exist and can be found by querying the id of that post

  2. 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.

Andy
  1. The answer to your first question is that the Facebook Graph API only returns a subset of fields by default. If you want different fields you need to specify which ones you want. This is mentioned in the Graph API docs:

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")
  1. The picture field for a post will only return a single picture (The picture scraped from any link included with the post.). To retrieve all of the pictures use the attachments edge which will return a list of all attached images (or videos etc).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Facebook Graph API call not returning all fields

From Dev

facebook graph api fields not returning

From Dev

Facebook Graph API calls not retrieving all fields

From Dev

Facebook graph API get all fields data

From Dev

facebook graph api - missing fields

From Dev

Facebook Graph API Post with a place

From Dev

Facebook Graph API is returning empty data

From Dev

Facebook graph API for videos not returning expected data

From Dev

Facebook Graph API is returning empty data

From Dev

Facebook graph web API not returning response as JSON

From Dev

Facebook graph API for videos not returning expected data

From Dev

Facebook graph api returning results in local language

From Dev

Graph API not returning all tagged in photos

From Dev

How to post a video using Facebook Graph API

From Dev

Post photo on Facebook group using graph api

From Dev

Post Picture Facebook - Graph API - PHP

From Dev

Post Image to the Facebook using Graph API

From Dev

Post Image to the Facebook using Graph API

From Dev

Post photo on Facebook group using graph api

From Dev

Facebook Graph API - Getting All Friends Likes

From Dev

Facebook Graph API: Find graph object from post URL

From Dev

Facebook Graph API v2.4 not returning extended user data

From Dev

Facebook graph api v2.4 not returning birthday

From Dev

Facebook Graph API v2.4 not returning extended user data

From Dev

Facebook-Graph-API get post by post id

From Dev

Displaying Specific Fields from Facebook Graph API JSON

From Dev

Facebook API: Get all likes of a post

From Dev

Facebook Insights API is returning no data (empty array) for a post

From Dev

Facebook Graph API: Making public post on user's page

Related Related

HotTag

Archive