【问题标题】:Facebook posts retrieval in androidFacebook 在 android 中的帖子检索
【发布时间】:2013-01-23 01:50:29
【问题描述】:

我正在尝试使用下面给出的代码在我的 android 应用程序中检索 facebook 的最新帖子。但它只给了我我的股份和 cmets。我想获得这些以及我在我的状态上发布的消息,但它总是为空。

Bundle params = new Bundle();
params.putString("format", "json");
params.putString("access_token",sp.getString("access_token",null));
String url = "https://graph.facebook.com/me/feed";
String response = Util.openUrl(url, "GET", params);
JSONObject json = Util.parseJson(response);
JSONArray jsonArray = json.optJSONArray("data");

if(jsonArray != null) {
i=0;
String tempName = jsonArray.getJSONObject(i).getString("from");
String tempId = jsonArray.getJSONObject(i).getString("id");
String story = jsonArray.getJSONObject(i).getString("story");
String msg = jsonArray.getJSONObject(i).getString("message");
}

在这里,如果我在我的状态上发布一些文本,那么“msg”也是空的。

请提供您的建议。谢谢。

【问题讨论】:

    标签: android facebook post feed


    【解决方案1】:

    您的应用需要拥有“read_stream”权限才能访问非公开帖子。请参阅User API reference 的“连接”部分,了解其他方法可能需要的其他权限。

    您可以先使用Graph API Explorer 尝试您的请求。

    【讨论】:

    • 它有所有的权限,但我想读取实时数据?
    • 我不确定你的意思。一旦我授予我的应用 read_stream 权限,每次我发出 /me/feed 请求时,我都可以看到我发布的最新帖子。
    • 我可以得到除message字段外的所有内容
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多