gpt4 book ai didi

java - 如何使用 Graph API 获取未读消息?

转载 作者:行者123 更新时间:2023-11-29 21:04:43 25 4
gpt4 key购买 nike

我正在开发一个获取 Facebook 未读收件箱消息的应用。

以下 v2.0 FQL 查询工作正常:

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

因此,我们有一个所有未读消息的列表。


但是,Facebook says :

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.

因此,我正在寻找一种仅使用 Graph API 的方法。我尝试了以下方法:

Bundle params = new Bundle();
params.putString("unread", ">0");
new Request(session,"/me/inbox/",params,HttpMethod.GET,new Request.Callback() {
public void onCompleted(Response response) {
...
}
}
).executeAsync();

没有成功。我得到了所有的线程,而我只需要未读的线程。那怎么办呢?

最佳答案

很抱歉的建议I gave当我盲目引用以下 Facebook 通知时:

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.

这句话是对的,但遵循它并不是很明智。


确实,我进一步检查发现:

没想到Graph API这么弱。 Graph API 使得无法通过过滤任何字段来构建请求。例如,我们不能做一些简单的事情,例如:

  • me/threads?unread_count>0,
  • me/threads?fields=unread_count.more(0)

现在使用 Graph,您必须遍历所有线程并检查哪个线程有 unread > 0。你会失去时间和带宽。此外,message 表甚至没有 unread 字段,这使您无法找到任何特定的未读消息。

所以,最好的办法就是继续使用 FQL。你现在安全了。到 2016 年,Facebook 可能会改进我们使用 Graph API 进行查询的方式。

等着瞧吧

关于java - 如何使用 Graph API 获取未读消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24940168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com