Android Facebook SDK 3.0阅读通知

Wen*_*ger 4 android facebook-graph-api

我遇到了Facebook图形API的问题,没有为获取用户通知的请求返回任何内容.我是通过批处理请求,使用相同的语法来获取用户的新闻源,并且新闻订阅源请求正常工作.我也启用了"manage_notifications"权限.当我尝试将图形调用的结果解析为通知时,我总是在代码中得到一个空指针异常.

请注意,当我在我的互联网浏览器中访问图形浏览器并输入"我/通知?include_read = true"时,我会获得相应的数据.

这是我的请求的代码.

static Request notificationsRequest = Request.newGraphPathRequest(fbSession, "me/notifications?include_read=true", new Request.Callback() {

    @Override
    public void onCompleted(Response response) {
        GraphObject object = response.getGraphObject();
        if(object != null){
            notifications = object.getProperty("data").toString();
        }
        else{
            notifications = "Notifications returns null";
        }

    }
});
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?谢谢.

编辑:我更新了代码,发现GraphObject对象返回null,这就是为什么它无法解析它的原因.看起来图形请求会出现问题,但我无法弄清楚它是什么.就像我说的,获取用户新闻源("我/家")的完全相同的方法完全正常.

C A*_*thy 6

不是在Graph路径中传递参数,而是将其作为参数添加到请求中:

我/通知?include_read =真

static Request notificationsRequest = Request.newGraphPathRequest(fbSession, "me/notifications", new Request.Callback() {

    @Override
    public void onCompleted(Response response) {
        GraphObject object = response.getGraphObject();
        if(object != null){
            notifications = object.getProperty("data").toString();
        }
        else{
            notifications = "Notifications returns null";
        }

    }
});


Bundle params = new Bundle();
params.putString("include_read", "true");

notificationsRequest.setParameters(params);
Run Code Online (Sandbox Code Playgroud)