Read Messages in Facebook
I have been trying to read the messages from a particular user (friend).
I couldn’t find a proper documentation in graph API regarding querying messages or threads in Facebook messages.
Can anyone please help me?
You can only read messages for the user using your app, not for his friends. (And that’s a good thing …)
For doing it for the current user, see here: https://developers.facebook.com/docs/reference/api/user/ (inbox & outbox connections)
It's currently hard to do it because you have to pull the full response from me/inbox
If you know the thread id beforehand you can maybe get it but /thread_id doesn't seem to be working well.
So to currently get it, check for the friend id in the to field within the response of each thread object.
you can use it like this:
https://graph.facebook.com/fql?q=select thread_id,subject,recipients, snippet, snippet_author from thread where folder_id = 0 and [FRIEND_ID] in recipients
Then you get all threads where your friend is. Then you can check from those threads that thread where only you and this friend are the recipients.
And then you can get the messages using:
https://graph.facebook.com/fql?q=SELECT message_id, thread_id, author_id, body, created_time, attachment, viewer_id FROM message WHERE thread_id = [THREAD_ID]