I'm trying to build a Java desktop app which will log onto Facebook's servers using the RestFB library, fetch the last 25 messages from each of the last 10 people the user has spoken with, and show a popup if their name is called.
So far I've got to log into Facebook with an app's appID & appSecret, and got a token.
My question is: On the official Graph API docs, they say that the "read_mailbox" feature is now obsolete and would only work for pages the user is admin on. They also say that it's been removed after Graph API 2.4 (i'm using 2.6). How could I read the user's private messages with Graph API 2.6? Note that when i'd be searching for messages, I would NOT know the last 10 people the user spoke with. This question has been answered already, but for that solution you HAVE to know the conversationID (which i want to fetch, not provide)
The read_mailbox permission is only used if you like to access the mailbox of a user. The page mailbox requires the read_page_mailbox permission.
A Facebook user should use the Facebook messenger, that's why the permission is deprecated and you find this section in the description of that permission
This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. For example, Android and iOS apps will not be approved for this permission. In addition, Web, Desktop, in-car and TV apps will not be granted this permission.
Besides this the technical part should work like this:
First you need the conversations. They are ordered by updated_time so you get the last conversations in correct order. You only need the first 10 conversation ids.
me/conversations?limit=10&fields=updated_time
Then you take every single conversation id and fetch the messages. For example with this call:
<conversationid>/messages?limit=25
As some hint, you can work with the fields and use a call like:
me/conversations?fields=messages.limit(25)&limit=10
to get everything you like to know in one call, but perhaps the requested data is too much and Facebook returns an exception. That's why I propose the first way to fetch the data.
You can translate these calls to RestFB by having a look at the documentation.