Android的Facebook的SDK - 如何查询Facebook的通知 [英] Android Facebook SDK - How To Query Facebook Notifications

查看:204
本文介绍了Android的Facebook的SDK - 如何查询Facebook的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Facebook的SDK为Android工作在我的应用程序。我似乎无法找到如何使用SDK code得到通知的任何实例或文档中。我的权限manage_notifications设置,我假设我需要使用.request()方法,但graphPath参数躲开我。

I have the Facebook SDK for Android working in my app. I can't seem to find any examples or documentation on how to use the SDK code to get Notifications. I have the permission "manage_notifications" set and I am assuming that I need to use the .request() method, but the graphPath parameter eludes me.

有没有人有一个如何得到使用Facebook SDK为Android Facebook的通知的例子吗?

Does anyone have an example of how to get the Facebook notifications using the Facebook SDK for Android?

推荐答案

而对方的答案是有帮助的,我一直在寻找的是Android的code的例子。我已经想通了,虽然并把它贴在这里。在code以下获取登录/身份验证的用户通知。

While the other answers are helpfull, what I was looking for was an example of the Android Code. I have figured it out though and have posted it here. The code below gets the logged in/authenticated users notifications.

//Initialze your Facebook object, etc.
Facebook _facebook = ...
...
Bundle bundle = new Bundle();
bundle.putString(Facebook.TOKEN, _accessToken);
String result = _facebook.request("me/notifications", bundle, "GET");

然后,你将需要解析字符串结果。这是JSON格式。这里是什么看起来像一个例子:

Then you will need to parse the string "result". It's in json format. Here is an example of what that will look like:

JSONObject jsonObjectResults = new JSONObject(result);
JSONArray jsonNotificationDataArray = jsonObjectResults.getJSONArray("data");
for (int i=0;i<jsonNotificationDataArray.length();i++)
{
    JSONObject jsonNotificationData = jsonNotificationDataArray.getJSONObject(i);
    if (_debug) Log.v("Title: " + jsonNotificationData.getString("title"));
}

我希望其他人发现这很有用。

I hope that other people find this useful.

这篇关于Android的Facebook的SDK - 如何查询Facebook的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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