Siva Natarajan
Siva Natarajan

Reputation: 1429

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?

Upvotes: 3

Views: 4423

Answers (3)

Juuso Kosonen
Juuso Kosonen

Reputation: 216

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]

Upvotes: 0

phwd
phwd

Reputation: 19995

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.

Upvotes: 0

C3roe
C3roe

Reputation: 96151

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)

Upvotes: 1

Related Questions