Graph API - Get latest news feed entries instead of "top news" - facebook

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.

Related

Facebook graphapi page/feed returning items sorted by relevance instead of recent activity

Hi I am using the Facebook graph api tool and attempting to get the feed of a public page. I want to get most recent comments first. However the feed returns comments and replies sorted by "relevance", is there a "sort" I can apply or how do I change this to get recent comments and replies within my posts?
I do not own the page I am getting the feed from.
There's the order parameter for comments, which can have the following values:
chronological
reverse_chronological
See
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5#ordering
As far as I know, the feed's posts will always be sorted by created_time, and there's no way to influence this via the Graph API requests.

FQL get posts from stream on updated_time, need to find equivalen Graph API

FQL will be obsolete in API 2.1. If any user creates a new APP, then the user is forced to use API 2.1 features, as a result, I need to remove all FQL and replaced with Graph API to server the new users who create a new app.
Here is the quesion, We use FQL to fetch all posts on wall based on updated_time, and then we can fetch all newly comments reply to these posts on the page. This is the way we can fetch all the newer comments since last update. the FQL syntax look like this.
https://graph.facebook.com/v2.0/fql?q=SELECT post_id, comment_info FROM stream WHERE source_id = ' owner ' and updated_time >=' since
Does any one know the equivalent feature in Graph API. I have been looking documents but unable to find it. Please help in coming out an alternate approach to achieve the same functionality, Thanks.
There's unfortunately no equivalent in the Graph API. The since request parameter is relative to the created_time AFAIK.

Get all latest entries in users news feed

Does anyone know of a way to retrieve the users entire news feed? Querying /me/home does filter some stories from. Also, it seems to retrieve the top stories. Is there any way to retrieve the latest stories?
It doesn't matter whether it's through the Graph API or FQL.
me/home is pulling posts in order of created date on my end
https://developers.facebook.com/tools/explorer/135669679827333/?method=GET&path=me%3Ffields%3Dhome.limit(20).fields(created_time%2Cupdated_time%2Cid)
try this as your query, you can mod fields to include any you need.
me?fields=home.limit(20).fields(created_time,updated_time,id)
if it is still out of order because of your cookie settings from the actual home feed, you can force it to reorder by passing the array in sort(); "php".
for sort() refer to: http://php.net/manual/en/function.sort.php

Facebook API: Can I access my page's user's content?

I'm trying to develop a management tool for my pages and to do that, I need access to the content my users post (as I repost a lot of their content - ex. photos)
It looks like I can get access to all the content that I post, but I can't seem to find any reference to features that'll allow me access to the user's content.
Is this not available in the API?
You can get all the posts for a page at:
https://graph.facebook.com/[PAGE_NAME_OR_ID]/feed?access_token=...
However, you can't filter on this very well. An option that gives you more control is FQL. This query of the stream table should get you started with posts by others.
SELECT post_id, actor_id, message, attachment, permalink FROM stream
WHERE source_id = [PAGE_ID] AND filter_key = 'others'
If a user has set their post to private, it won't be returned by this call. You also need to be aware of the limits of the stream table: It only returns up to 50 posts in the last 30 days. If you want more, you have to use a LIMIT clause to page through your results.
I am developing Facebook application from last two years as per my experience you can't get any users information and using Page Signed request you can get userid,isowner,timezone and isLiked only..

Obtain all comments posted to a Facebook social comments page using FQL

Is there a way to use FQL to obtain the XID of all comments posted on any page associated with a particular Facebook application ID?
The docs listed for FQL on the comments_info table at this address seem to suggest that it is possible:
http://developers.facebook.com/docs/reference/fql/comments_info/
If I attempt the following query however, it returns no results.
SELECT xid FROM comments_info WHERE app_id = {MY_APP_ID}
I want to use this to find the most popular pages without individually checking each URL to determine which one has the most posts.
If you are trying to get comments from the Comments plugin, try the comment FQL table instead. Legacy fb:comments were auto-migrated to the latest version a while ago, effectively rendering *comments_info* obsolete.
From the *comments_info* docs page:
"Note: This table contains a mapping of app_id to XIDs used by legacy fb:comments. It does not contain a map for the current comments plugin, which does not use XIDs."