Get a page's average number of posts / day using Facebook API? - facebook

I'm trying to figure out a way to calculate a Facebook page's average number of posts per day using the API. The problem is that the API does not show when the page was created. Instead, I'm downloading all the posts and using the oldest post as some sort of creation date (which is not 100 percent correct...).
The problem is when a page adds backdated posts. For instance, someone might post a picture in 2012 that's dated 2008. Then that post will be oldest, even if the page hasn't existed that long.
One solution is to go by the updated_time field instead of created_time, but it's not a great solution that still may not be correct.
Is there someway to get around this?
Sorry if this question has come up before, but I couldn't find anything on it.

Unfortunately what you're looking for isn't possible using the API.
For a given post two dates are returned - created_time and updated_time.
As you rightly pointed out the created_time can be updated to add a post in the past.
updated_time also will not work for you as this gets updated whenever someone comments on a post.
https://developers.facebook.com/docs/graph-api/reference/v2.3/post

Related

Getting Facebook page posts of the last hour/day etc

Is it possible to specify a time span for the posts returned by GET /v2.x/{page-id}/feed?
For example, I want all the posts of the last hour and only those...
EDIT: Just found the since and until fields for the feed. However, this only seems to apply to posts, not to comments on those posts...
Any way to apply the time span to both posts and comments, regardless?
Ideally, I would get a chronological list of messages (whether posts or comments) for the last X time units.
Graph API returns comments in same order as selected on actual post|picture|etc..
I already searched alot about this. Then i went for a stupid but simple solution. I can show you if you are willing to made 2 requests to graph api to get comments

Facebook Api getting feeds and comments

I'm trying to get the feeds on a public wall and the associated comments.
So every X minutes I'm doing a query in order to get what's new (feeds and comments).
I need the feeds (the new feeds since myDate) and comments (comments posted on the new feeds and comments posted on older feeds).
So if someone posted a comment on a older feed I want to get it.
I tryied to do this using FQL and Graph API but I don't manage to find the best solution.
With FQL there are some problems (bugs) with LIMIT and OFFSET and does not work very well.
With the Graph API I don't have so much power.
So this is what I've tryied:
https://graph.facebook.com/PAGE_ID/feed?access_token=MY_ACCES_TOKEN0&limit=500&since=1350033469&until=now&updated_time>1350033469
This gives me the newest post, so no problem because for each one I'm doing a new query in order to get the comments for each feed:
https://graph.facebook.com/PAGE_ID/comment?access_token=MY_ACCES_TOKEN0&limit=500&since=1350033469&until=now&updated_time>1350033469
The problem is that if a comment is posted on a older post, I don't receive it.
Using FQL I cannot filter only the newest posts (based on my since date) and the posts with new comments.
https://api.facebook.com/method/fql.query?query=SELECT post_id, text, fromid FROM comment WHERE post_id IN (SELECT post_id FROM stream where source_id=PAGE_ID and comments.created_date>1350033469)&access_token=MY_ACCES_TOKEN
Using Graph API I have a good pagination (using next and previous links inside the response) but with FQL I did't find any solution.
So anyone have some idea ?
Thanks.
C.C.
First, the FQL is deprecating, so you need to use only the Graph API.
The solution that I came with, is that when you already have a post, you need to recheck the post with its unique ID, and that request gives you two times, created_time and updated_time, so you need to check if your updated_time changed.
The pagination given in the Graph API is for only posts, so when posts have new comments, they won't come first in the list, you need to find them yourself.
-- UPDATE --
Use batch_requests to achieve this, so you can make more requests at a time.

"/me/feed?since=" set this 'since' to the updated time in stead of the created time

I have a application that monitors a businesspage for you, along with other sources like Twitter. For the purpose of internal comments and analytics I store the posts on the wall in our database.
Every 10 minutes I ask Facebook if there are new posts since the last time. I use "/me/feed?since=[10 mitutes ago]". The problem is when I have already stored the post and a new comment is added to this post, when I request the new posts this post is not returned.
I know this is because the created time is before the timestamp requested in the since call. But the updated time is not. Is there a way to set 'since' to the updated time in stead of the created time?
Extra case information
I also tried this using FQL instead of Graph API. But that method has a problem/bug.
I use this script on the pages of very large companies, like Heineken. On these pages, there are a few posts per hour and on busy times many posts per minute. But those are not the problem.
The problem is that I have a few posts, usually one or two a day, that are very interesting and have a lot of comments, and continue to have comments for days. Those 'large' posts are the most interesting of all, but they get suppressed out of my results because there are too many new posts.
Use FQL:
SELECT post_id FROM stream WHERE source_id = me() AND updated_time > YOUR_TIME_LIMIT
This gives you all posts to a user's wall (source_id = me()) which were updated after a certain time. The "updated_time" is changed when a user comments on the post.
To add fields to retrieve with the query, please have a look at the fields in the FQL stream table.

Facebook Graph API does not give any data earlier than 2011?

I'm the author of Fazzle app on iPhone. What my app does is basically download user status updates and sort them in various orders (e.g. most liked, most commented).
I have been wondering if Facebook allow developers to get user's status updates since the day they joined Facebook, because when I launched the app I can only get user statuses from 2009. Today I just discovered that Facebook limits Graph API calls down to just since 2011.
I tried looking at documentations, asked around here, and contacted Facebook through their forum. However so far there is no word on this limitation in Graph API. Did I miss something? Is there any other way for me to get data for status updates earlier than 2011?
You can test it yourself here. Use this GET request:
https://graph.facebook.com/(your_user_id)/statuses?limit=99999
Scroll down and you'll find out that not everything's downloaded.
Is this because of conflict of interest with Facebook Timeline? If so, that sucks.
Logged as a bug here. Still hoping someone can point out my mistakes if there's any.
Absolutely you can get older posts from Graph API; there is no limit (at least not that I am aware of). Use the since and until parameters to page back through results, instead of offset:
https://graph.facebook.com/me/feed?access_token=[token]&until=1165474447
Documentation for Paging doesn't go very in-depth on since and until:
When querying connections, there are several useful parameters that enable you to filter and page through connection data:
limit, offset: https://graph.facebook.com/me/likes?limit=3`
until, since (a unix timestamp or any date accepted by strtotime):
https://graph.facebook.com/search?until=yesterday&q=orange
But basically, until is like saying "Give me posts up until this date", and since is similar, "Give me posts since this date". So you can scroll all the way back through a user's feed using a loop something like this:
// pseudocode
timestamp = now
do {
posts = graph.get(/me/feed?until=timestamp)
if posts.length == 0: break;
// process posts
timestamp = posts[0].created_time // first should be the oldest, in theory
} while (1)
Replace until with since and oldest created_time with the newest to go forwards in time, e.g. to grab any newer posts since the last time the user ran the app.
Facebook has since confirmed this as a bug. If you have followed Facebook's bug tracker ever, unfortunately that means there is very little if any chance they will actually fix this.
You will need to paginate. Limit is limited. Please read http://developers.facebook.com/blog/post/478/

Graph api - Like / until - since

Is there a possibility to use the parameters "since" and "until" in the likes request?
What I'm trying:
https://graph.facebook.com/me/likes?limit=500&offset=0&since=2011-01-01&access_token=...
I liked a post today, but it is not working. It can only show 2 pages which I liked in the past.
When using FQL, it is working as expected, but the "since" nor "until" parameter are working..
Also tried with FQL, but can't get it working:
https://graph.facebook.com/fql?q=' . rawurlencode('SELECT object_id FROM like WHERE user_id = me() LIMIT 500') . '&access_token=...
I think it is not possible to use those parameters on a like, am I correct?
Have a look at the documentation for pagination, which is here.
At the time of this answer it says...
"The following Graph API connections are cursor-based with more coming soon:
/photos
/albums
/links
/notes
/admins
/comments
"
and it looks like there is already a bug filed requesting that '/likes' be added to the list as noted (it can be found here)
HOWEVER...
The likes come back in chronological order so you don't have to gather all of them to find the ones since a particular date. I've got no idea if you can count on this or not so use this at your own risk.
(A side note: I dream of the day when Facebook actually grows up enough to deliver a mature API.)