with Facebook Graph Api we can get all the fields definition by adding "?metadata=1" in the query.
With Facebook Insights I don't see how to retrieve all the metric fields (with their definition, code...)
Have you any idea to get / download this list in a usable format (csv, xml, text..)
Thanks.
Related
I'm trying to read some post information about some FB pages/profiles. I'm considering the Graph API version v2.8, and following this documentation.
But there are some fileds accessible from the Graph API that are not listed in the above link, for example the fields is_popular, target, promotion_status and timeline_visibility.
So far, the first two parameters didn't give me any result, but I can obtain both the promotion_status and timeline_visibility results from some posts. How can be possible that the set of the available fields in the reference and in the graph API tool are different for the same version of the API? Should I avoid to request these feelds and lean my word on them?
The Short Version:
"I can visit the public page without being logged into Facebook and see underneath the post is says "2155 shares" I would like to know how to access that number through the API"
The Details:
I'm trying to use the newest version (v2.5) of the graph HTTP API to determine the total share count for a public video. The problem is FB seems to have changed the API enough that older posts on SO no longer answer this question.
Looking at the Graph API Documentation it appears that video nodes now have the "sharedposts" edge. However, calling this route with summary=true only returns a few of the shares and no value for a total count. This returns counts for comments and likes so I'm not using the endpoints incorrectly or messing up my authorization.
I've also tried to use the URL Node but this doesn't seem to do much with links inside of Facebook. I simply get a JSON response with an 'id' field with the same url I supplied as a request parameter. Seems like this route is meant to be used for links to content outside of Facebook.
I've tried the above methods with multiple videos on multiple public pages so I don't think it is due to the group owners restricting access, unless this is the new default.
It seems arbitrary that I would be allowed access to total counts for comments and likes, but not shares. Is there some legacy way to do this or am I out of luck for now?
You should query the Post element containing the Video element.
Each video posted is also contained in a post element.
The post id is then composed of the video id prepended with the posting entities id (user, page etc'), separated with an underscore.
It then looks like: user-id_video-id.
Then using the Graph API to get the share count of a post is straightforward:
GET /v2.5/{post-id}?fields=shares
Example
Lets take a video from the BBC page:
https://www.facebook.com/bbcnews/videos/10153524838517217/
(Please tell me if the link is broken. I'll switch it to something newer :))
Video id : 10153524838517217
Page id (see below): 228735667216
--> Post id: 228735667216_10153524838517217
And the request would be:
GET /v2.5/228735667216_10153524838517217?fields=shares
(open in the Graph API explorer)
Page id
to get the page id, you could query the video element for the from field.
GET /v2.5/10153524838517217?fields=from
I tried for several hours to get the total number of likes/comments of a photo/post using the new Facebook Graph API 2.1 but I didn't find how to do it.
I am able to photo and post details through the API but it contains only an subarray with some likes and comments (ID/Name pair), but no the total number. Graph API Reference for object/likes mention a total_count field but is not able to found in API response.
Can you please suggest me a way to do it?
I am using latest Facebook PHP SDK 4.
I faced this situation before. Facebook Graph API Explorer, in the Fields dropdown list, you can not find any field related to total_like or total_comment of a specific post ( via its object_id). That means Facebook Graph API does not support getting the total likes, comments of a specific post.
But, it support to get likes, comments data of a post via likes, comments fields. So by this way, you can get the entire data about likes, comments, therefore, you can get the total number of likes/comments. This solution is not good, I think. I think in the near feature, Facebook Graph API support the fields total_likes, total_comments.
/object_id?fields=comments.limit(1000),likes.limit(1000)
When I lint a URL through Facebook's Linter / Debugger, it generates a Graph Object structured like [Obj#1] https://graph.facebook.com/380728101301 (I'm using Facebook's IMDB example so it's clear it's not just me). While this object has an id associated with it, this id does not work as a pageId in Graph API functions (pages.isFan for example).
Previously, it was the case that I could access the same Graph Object I had linted by using that object's URL as the id in the Graph. For the IMDB example, that's https://graph.facebook.com/?id=http://www.imdb.com/title/tt0117500/ (this also maps to [Obj#2] graph.facebook.com/114324145263104 if you just swap the id from the result back into the URL).
However, even though it seems like that should be the same graph object as what was linted, it is a different object with a different id. This object's id can be used with the open graph api functions, but the object itself is not actually generated until someone has explicitly liked the URL, which is not particularly convenient.
So not only does the linter no longer seem to generate usable objects on its own, but it also appears that two different objects are being generated by Facebook from the same metadata at the same url. Confusing.
My questions are:
1) What is the difference between these two Graph Objects?
Obj#1 -- graph.facebook.com/380728101301
Obj#2 -- graph.facebook.com/114324145263104
2) Is there still a way to generate an Graph Object with a valid pageId (like Obj#2) before someone has explicitly liked the page the og metadata is on?
https://graph.facebook.com/380728101301 (I'm using Facebook's IMDB
example so it's clear it's not just me). While this object has an id
associated with it, this id does not work as a pageId in Graph API
functions (pages.isFan for example).
pages.isFan is not a graph API function but a legacy REST API method. from pages.isFan doc:
Checks whether a user is a fan of a given Page. Doesn't work for
Application about Pages.
your first id = application about page, that's why it doesn't work.
hope this helps
I'm working on a module to my web application which is supposed to display latest news feed entries for a specific user.
I was wondering if it's possible to add a certain "orderby" parameter to the graph api url in order to fetch the "latest news" instead of facebook's default "top news" which arranges the order using popularity and other elements.
I'm currently using the following url:
https://graph.facebook.com/me/home?access_token=...&limit=10
but again, this does not return the latest entries.
Does anyone know how to solve this?
You can use FQL rather then Graph to query the "stream" table. FQL supports order by statements similar to SQL. http://developers.facebook.com/docs/reference/fql/
For your specific example it would be
SELECT post_id FROM stream WHERE source_id=me() ORDER BY updated_time DESC
Obviously you will want to query more then just the post_id, you can find the full list of fields here http://developers.facebook.com/docs/reference/fql/stream/
Mikey, I've been trying to do the same thing. During my tests I found that the Facebook API didn't return all the entries it was supposed to.
Meaby in some way it's prevent you from seeing all updates correctly.
Try this :
In your browser open : https://graph.facebook.com/me/home?access_token=
then
Go to the Facebook Graph API Doc : https://developers.facebook.com/docs/reference/api/
and click the News feed: https://graph.facebook.com/me/home?access_token=... link in the page.
Check if the two page show the same output.