user1859900
user1859900

Reputation: 81

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 ?

Upvotes: 1

Views: 20129

Answers (1)

林果皞
林果皞

Reputation: 7813

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

Upvotes: 4

Related Questions