How to get unread messages using FQL?

后端 未结 4 1982
情话喂你
情话喂你 2021-01-19 06:16

I am trying to get the body and the sender of all unread inbox .

To get all conversation\'s threads with unread messages I used this query:

SELECT thre

4条回答
  •  佛祖请我去吃肉
    2021-01-19 07:04

    This works:

      SELECT sender, body FROM unified_message 
       WHERE thread_id IN 
             (SELECT thread_id FROM unified_thread WHERE folder = 'inbox' AND unread=1) 
         AND unread=1 
    ORDER BY timestamp DESC
    

    It is important to sort the messages you retrieve in a descending order using:

    ORDER BY timestamp DESC
    

    Otherwise, only the first older messages of the conversation will be examined, whereas unread messages should be recent.


    Just for your knowledge, here is the corresponding multi-query, which gives the same result:

    {
     "threads":"SELECT thread_id FROM unified_thread WHERE folder='inbox' AND unread=1",
     "messages":"SELECT sender, body FROM unified_message WHERE thread_id IN (SELECT thread_id FROM #threads) AND unread=1 ORDER BY timestamp DESC"
    }
    

    However, you should not use FQL anymore:

    Version 2.0 of the Facebook Platform API is the last version where FQL will be available. Versions after 2.0 will not support FQL. Please migrate your applications to use Graph API instead of FQL. Please see our changelog for current version information.

    I suggest you use the following Graph API tables:

    • thread
    • message

    By the way, FQL doesn't have such INNER JOIN.

提交回复
热议问题