Search code examples
facebook-graph-apifacebook-fqlmessageinbox

Facebook FQL query to get user's sent messages since a timestamp


I'm not too familiar with Facebook FQL. I'm looking for a way to see what users have received my message. I know I need to ask for extended permissions read_mailbox

For instance I would like to see if my message "hello" has been sent after 2013-05-02 14:00 and which recipient userIDs has it been sent to.

Input for the query would be the message "hello" and from timestamp "2013-05-02 14:00" to current timestamp.

Output from the query would be a list of userIDs that have been sent the message "hello" since the timestamp 2013-05-02 14:00


Solution

  • After some trial and error I found a solution:

    NSString *query = [NSString stringWithFormat:
    
    @"{"
    @"'query1':'SELECT thread_id FROM message WHERE thread_id IN "
    @"(SELECT thread_id FROM thread WHERE folder_id = 1 AND updated_time >= \"%.f\") "
    @"AND author_id = me() and body = \"%@\","
    @"'query2':'SELECT recipients, thread_id FROM thread WHERE thread_id IN (SELECT thread_id FROM #query1)'"
    @"}",
    
    self.sendTime, self.facebookText];