如何使用FQL获取未读邮件? [英] How to get unread messages using FQL?

查看:157
本文介绍了如何使用FQL获取未读邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让身体和所有未读的收件箱的发送者。

要获得所有谈话的主题有未读邮件我用这个查询:

从unified_thread选择的thread_id其中folder =收件箱和未读= 1

要获得一个线程我用这个查询的未读消息

选择发件人,身体unified_message WHERE未读= 1

我曾尝试以下嵌套查询:

 选择发件人,身体unified_message WHERE的thread_id IN(选择的thread_id从unified_thread其中folder =收件箱和未读= 1)和未读= 1
 

但我只得到一封未读邮件从一个线程,而不是所有的未读线程。

像这样

我也试过multiquery:

 字符串QUERY1 =选择的thread_id从unified_thread其中folder =收件箱和未读= 1;
字符串query2 =SELECT时间戳,发件人,身体unified_message WHERE未读= 1 AND THREAD_ID IN(选择的thread_id FROM#QUERY1);
捆绑PARAMS =新包();
JSONObject的jsonFQL =新的JSONObject();
尝试 {
        jsonFQL.put(QUERY1,QUERY1);
        jsonFQL.put(query2,query2);
}赶上(JSONException E){
        e.printStackTrace();
}

params.putString(法,fql.multiquery);
params.putString(查询,jsonFQL.toString());
新的请求(会话,/ FQL,参数,可以HttpMethod.GET,新Request.Callback(){
      公共无效onCompleted(响应响应){
                                     ...
                                 }
                     ).executeAsync(); ....
 

但我得到了错误:

  

的errorMessage:不支持的方法,fql.multiquery

然后我试着用INNER JOIN:

  SELECT unified_message.sender,unified_message.body
            从unified_message
            INNER JOIN unified_thread
            ON unified_message.thread_id = unified_thread.thread_id
            WHERE unified_thread.unread = 1
 

但我得到这个错误:

  

分析器错误:意想不到的内在的位置...

我学到JOIN不支持FQL

有人可以给我一个手办这个查询FQL ??

例如需要输出的:我有不同的人交谈5,但只有3谈话有未读信息。所以,我想获得 是这样的:

 未读邮件

发件人:安娜
正文:你好花花公子
正文:你怎么样?
正文:我想念你

发件人:约翰
正文:请帮我

发件人:埃里克
正文:漂亮
正文:好友
 

解决方案

本作品:

 选择发件人,身体unified_message
   WHERE的thread_id IN
         (选择的thread_id从unified_thread其中folder =收件箱和未读= 1)
     和未读= 1
ORDER BY时间戳降序
 

要你在一个递减顺序检索使用的消息进行排序是非常重要的:

  ORDER BY时间戳降序
 

否则,只有第一个年长谈话的消息会被检查,而封未读邮件应该是最近的事。


就为了你的知识,在这里是相应的多查询,可以得到相同的结果:

  {
 主题:选择的thread_id从unified_thread其中folder =收件箱和未读= 1,
 消息:选择发件人,身体unified_message WHERE的thread_id IN(选择的thread_id从#threads)和未读= 1 ORDER BY时间戳降序
}
 

不过,你不应该使用FQL了:

  

Facebook平台的API 2.0版本是最后一个版本,其中FQL   将可用。 2.0之后的版本将不支持FQL。请   迁移应用程序来使用图形API,而不是FQL。请参见   我们的更新日志的当前版本信息。

我建议你使用下面的图形API表:


顺便说一句,FQL没有这样的 INNER JOIN

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 thread_id from unified_thread WHERE folder='inbox' AND unread=1

to get the unread message of a thread I used this query

SELECT sender,body FROM unified_message WHERE unread=1

I have tried the following nested query :

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"

but I only get unread message from one thread and not all unread threads.

I also tried multiquery like this:

String query1="SELECT thread_id FROM unified_thread WHERE folder='inbox' AND unread=1";
String query2="SELECT timestamp,sender,body FROM unified_message WHERE unread=1 AND thread_id IN (SELECT thread_id FROM #query1)";
Bundle params = new Bundle();
JSONObject jsonFQL=new JSONObject();
try {
        jsonFQL.put("query1",query1);
        jsonFQL.put("query2",query2);
} catch (JSONException e) {
        e.printStackTrace();
}

params.putString("method","fql.multiquery");
params.putString("queries", jsonFQL.toString());
new Request(session,"/fql",params,HttpMethod.GET,new Request.Callback(){
      public void onCompleted(Response response) {
                                     ...
                                 }
                     ).executeAsync(); ....

but I got error:

errorMessage: Unsupported method, fql.multiquery

Then I tried with INNER JOIN:

SELECT unified_message.sender,unified_message.body 
            FROM unified_message 
            INNER JOIN unified_thread 
            ON unified_message.thread_id=unified_thread.thread_id
            WHERE unified_thread.unread=1

but I got this error:

Parser error: unexpected 'INNER' at position...

I learnt JOIN is not supported in FQL

Can somebody give me a hand to do this query in FQL ??

example of needed output: I have 5 conversations with different people, but only 3 conversations have unread messages. So I would like to get something like this:

UNREAD MESSAGES

Sender: Anna 
Body: hello dude 
Body: how are you? 
Body: I miss you

Sender: John
Body: please help me 

Sender: Erick 
Body: nice
Body: buddy

解决方案

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:


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

这篇关于如何使用FQL获取未读邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆