Facebook 好友信息与 Facebook Android SDK、JSON 破坏

发布于 2024-12-26 00:20:24 字数 1262 浏览 5 评论 0原文

陷入了困境。我对安卓完全陌生。 我使用 Facebook Android SDK https://github.com/facebook/facebook-android-sdk

我遵循了本教程 http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/

这可以帮助我登录并发布到用户的墙上。现在我想收集朋友的信息。

从本主题 适用于 Android 的 Facebook API:如何获取有关用户好友的扩展信息? 我找到了一个简单的方法来做到这一点。

Bundle bdle=new Bundle();
    bdle.putString("fields","birthday");
JSONObject json = Util.parseJson(facebook.request("me/friends",bdle));

现在,当我打印这个 json 时,我可以看到 id 和出生日期。现在我找不到分离它们的方法,也没有在搜索中找到任何内容。它给了我所有朋友的 ID 和出生日期。类似的东西:

{"data":[{"id":"12345","birthday":03/29"},{"id":"12678","birthday":06/22"}],.. ......

我更喜欢这个,因为它可以防止应用程序获取单个朋友的 ID 来获取单个日期,而是完全为我提供。

现在请帮我打破这个 json 并将这些信息分成两个数组,例如 a[1]="12345";b[1]="03/29"

如果有人可以在 facebook 上为我提供任何简单的示例/教程链接与 android 集成,特别是以异步方式集成,这将是一个很大的帮助。

Got stuck in a situation. I'm totally new to android.
I used Facebook Android SDK https://github.com/facebook/facebook-android-sdk

I followed this tutorial http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/

this helps me to log in and post to user's wall. Now I want to collect friends' information.

From this topic Facebook API for Android: how to get extended info regarding user`s friends?
I found a simple way to do that.

Bundle bdle=new Bundle();
    bdle.putString("fields","birthday");
JSONObject json = Util.parseJson(facebook.request("me/friends",bdle));

Now when I print this json,I can see id and birth dates. Now I can't find a way to separate them and also not found anything on search. It gives me all friends' ID and birth dates all together. something like :

{"data":[{"id":"12345","birthday":03/29"},{"id":"12678","birthday":06/22"}],.......

I preferred this ,because it prevents application to fetch a single friend's id to get a single date,rather provides me altogether.

Now please help me to break this json and separate this information into two array,like a[1]="12345";b[1]="03/29"

And if anyone can provide me any simple example/tutorial link on facebook integration with android specially in asynchronous way that would be a great help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2025-01-02 00:20:24

(在问题编辑中回答。已转换为社区 wiki 答案。请参阅 问题没有答案,但问题在评论中解决(或在聊天中扩展)

OP 写道:

解决了问题:

JSONArray jsonarr=json.getJSONArray("data");
JSONObject j=jsonarr.getJSONObject(0);
s1=j.getString("name");
s2=j.getString("birthday");

(Answered in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

Solved the problem:

JSONArray jsonarr=json.getJSONArray("data");
JSONObject j=jsonarr.getJSONObject(0);
s1=j.getString("name");
s2=j.getString("birthday");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文