如何使用新的Graph API获取用户通知

use*_*898 11 facebook

即时切换到新的Graph API,我尝试用新的Graph api替换所有其余的api阅读文档我看到我有某种实时功能(我不确定它与获取用户通知有关)假设给我回电.但在我的情况下,我喜欢调用简单的http命令,并获得用户通知(如旧的通知api),我现在该怎么办?谢谢

Cra*_*ack 13

GraphAPI方式:您可以通过访问通知USER_ID/notifications,它需要manage_notifications权限.

图API API Explorer示例


Gun*_*son 9

如果您想通过图谱API 获取所有最近的通知,包括阅读通知,请致电:

graph.facebook.com/USER_ID/notifications?include_read=true
Run Code Online (Sandbox Code Playgroud)

这可用于测试目的.


syo*_*kit 2

截至 2010 年 8 月 1 日,新的 Graph API 中仍然没有通知方法(我不确定是否有任何迁移计划)。为此,您需要使用旧的 REST API。

使用 FB.api 代替旧的 REST API。它可能是这样的:

FB.api(
  {
    method: 'notifications.get'
  },
  function(response) {
    alert("Number of unread messages: " + response.messages.unread);
  }
);
Run Code Online (Sandbox Code Playgroud)