FQL - Get all post in the wall of a user - facebook

I need to get all me() wall posts.
I am using the following FQL:
SELECT post_id, comments, message
FROM stream
WHERE source_id = me()
AND created_time > 946684800 AND created_time < now()
but this only returns 7 entries, where as a matter of fact there must be much much more..
(NB 946684800 = Sat, 01 Jan 2000 00:00:00 GMT)
I also tried to use the following query:
SELECT post_id, actor_id, target_id, message, comments
FROM stream
WHERE source_id = me()
AND is_hidden = 0
ORDER BY created_time
DESC LIMIT 1000000
that although it returns 394 entries, the earliest data is Mon, 30 Apr 2012 12:56:04 GMT, where for it must go back more.
I need to have in possession the whole wall posts a user have submitted.
Any ideas before I get frustrated even more :) ?

just notice as facebook announced, as of February 6th, 2013 offset no longer allowed when searching posts. Use 'since' and 'until' to do paging instead.

Simple answer to your question is...you can't get all posts on the wall with just one query, you will have to loop and make more requests to get further posts.
You can also check this blog post on paging made by Facebook to understand more clearly as to how the result are sent by Facebook. Also remember the maximum results you can have before Facebook trims it for visibility checks is 5000 as mentioned in the post.

Related

Facebook API finding status created time

When I call the /statuses endpoint I only get a updated_time field and not a created_time field (like I do when calling /photos or /links). It seems that updated_time is the time this post was last liked or commented, and it appears even setting the since parameter in the query returns statuses that were created before since but were updated after.
Is there any reason for this difference between /statuses vs. /photos and /links?
Can I get a created_time for a status and query since accordingly?
Better use FQL for this time. It has always been more complete than Graph.
SELECT time, message FROM status WHERE uid = me()
time uid
UNIX timestamp of the date and time the status message was posted
https://developers.facebook.com/docs/reference/fql/status/

Facebook: Get facebook messages for specific Date?

I wanted to get facebook's messages not Feeds. I've searched about it but did not find the solution.
I have also looked into FQL for the same but didn't find any useful things.
Is it possible to get messages from facebook with specific date ? OR just messages ?
It's possible you get lastest facebook messages on top of thread(conversation session) by specific time with fql API, such as
SELECT snippet, recent_authors, updated_time FROM thread WHERE folder_id = 0 AND updated_time=1364564697
Also, it's possible you get facebook message by specific time with API within thread. Such as
SELECT body, created_time FROM message WHERE thread_id=1774741570083 AND created_time=1348806942
For your question. Yes. It's possible get facebook message from ALL
inbox messages by specific DATE(by DATE, not by TIME, as your
request). Example, get all inbox messages from "Thu Aug 23 2012
00:00:00 GMT+0800 (MYT)" to "Fri Aug 24 2012 00:00:00 GMT+0800
(MYT)"
SELECT body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0) AND (created_time>=1345651200 AND created_time<1345737600)
Update:
To retrieve sender name and profile photo, you can do
{"query1":"SELECT author_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0) AND (created_time>=1345651200 AND created_time<1345737600)","query2":"SELECT id, name, pic_square FROM profile WHERE id IN (SELECT author_id FROM #query1)"}
Update:
HTTP GET request example, quote the fql query, append to
https://graph.facebook.com/fql?format=json&q=
After that, append &access_token=YOUR_USER_ACCESS_TOKEN at the end:
https://graph.facebook.com/fql?format=json&q=%7B%22query1%22%3A%22SELECT+author_id%2C+body%2C+created_time+FROM+message+WHERE+thread_id+IN+%28SELECT+thread_id+FROM+thread+WHERE+folder_id+%3D+0%29+AND+%28created_time%3E%3D1345651200+AND+created_time%3C1345737600%29%22%2C%22query2%22%3A%22SELECT+id%2C+name%2C+pic_square+FROM+profile+WHERE+id+IN+%28SELECT+author_id+FROM+%23query1%29%22%7D&access_token=ACCESS_TOKEN

Facebook get wall by time limit

I am getting wall posts by facebook sdk
$get = $facebook->api('/me/posts', 'GET' );
or
$get = $facebook->api('/me/feed', 'GET' );
I need to save them into my own DB, and after new request, I need get posts, that I have not saved yet. But I could not find any parameters to add to get info for example last 7 days, or after post by timestamp smth.
I saw that there is FQL which has time field, but it was only in Statuses table, I need all of them, likes, shares, statuses, comments etc.
Can anyone help me?
You can add since=[time] and/or until=[time] as query strings to get a specific slice of time.
For instance, to get 7 days of posts beginning on October 1, 2012, try this:
'/me/feed?since=2012-10-01&until=2012-10-08'
Your time string can be either an ISO-8601 date string or a UNIX timestamp.

FQL geting the Number of messages between you and someone at a certain time

See I want to know the message count between me and my friends but not the total over time but at a time I decide for example between july 2010 and december 2010 but there are no way to specificy a timestamp or until parameter in this query
I already tried
SELECT num_messages,timestamp ,senders, thread_id FROM unified_thread WHERE
CONTAINS('STRING') and thread_id= 'THREAD_ID'
I also tried
SELECT num_messages,timestamp ,senders, thread_id FROM unified_thread WHERE
single_recipient=USER_ID
but in this one the timestamp represents the last time the thread was updated so I cant filter by timestamp because it returns the same or nothing.
I finally got to this
SELECT message_id,body,created_time FROM message
WHERE thread_id = THREAD_ID (INT EXPECTED - OLD SYSTEM )
here I get each message and a timestamp from where the message was sent but is there a way to get FQL to count them for me ?
No. There is no count method in FQL. You have to bring the results back to your script and count them there.

Formatting dates with FQL

I'm trying to do the following Facebook Query Language query:
https://api.facebook.com/method/fql.query?query=SELECT name FROM user WHERE uid IN (SELECT actor_id FROM stream WHERE app_id = 131580206909839 AND xid = 'daily_thred_production' AND created_time > 2011-03-06 AND created_time < 2011-03-08)
The problem is that the dates aren't being recognized and I can't find any documentation on how to format FQL dates from the Facebook developer section. Any thoughts?
EDIT
I'm doing all of this from the URL with no programming language. I'm just trying to pull one-off statistics for some co-workers.
Epoch time seems to work, thanks! Only problem is that it's only displaying new users that contributed to the stream for the first time. Unfortunately I'm trying to find everyone in the stream, I'll have to look at the stream table more carefully.
Thanks Brian.
They're epoch time (Number of seconds since 00:00:00 Jan 1, 1970 UTC)
You need to convert your dates to epoch time in whatever language you're using.
EDIT: If you need an example, let me know what programming lang you're using.