如何解析的Facebook数据 [英] How to Parse Facebook Data
问题描述
我有获得Facebook的数据的几个问题来分析正确。
I am having a few problems getting Facebook data to parse properly.
我正在实现一个应用程序的一部分,允许用户选择和使用的应用程序在自己的Facebook的照片之一。我已经得到了Facebook的登录/注销code的工作和我目前得到的令牌(登录后),以收集用户相册的信息。该权限集也是工作很好,但我现在停留在试图获得JSON的信息,正确分析。这里是信息的示例代码段我需要解析:
I am working on implementing part of an application to allow a user to select and use one of their own facebook photos within the app. I have gotten the facebook login/logout code working and I am currently getting the token (once logged in) in order to gather the users Album information. The permission set is also working nicely, however I am now stuck at trying to get the JSON information to parse correctly. Here is a sample snippet of the information I need to parse:
"data": [
{
"id": "3486732467234",
"from": {
"name": "Persons Name",
"id": "Persons ID"
},
"name": "Vacation",
"location": "City",
"link": "https://www.facebook.com/album.php?fbid=434235&id=324343&aid=2430",
"cover_photo": "3489234432",
"privacy": "everyone",
"count": 60,
"type": "normal",
"created_time": "2007-06-03T23:01:16+0000",
"updated_time": "2011-03-18T19:46:43+0000",
"can_upload": true
},
{
"id": "4043544665",
"from": {
"name": "Persons Name",
"id": "Persons ID"
},
"name": "Vacation 2",
"location": "City",
"link": "https://www.facebook.com/album.php?fbid=4043434665&id=508154335&aid=2555",
"cover_photo": "5434543",
"privacy": "everyone",
"count": 60,
"type": "normal",
"created_time": "2007-06-03T22:53:03+0000",
"updated_time": "2011-03-18T19:45:55+0000",
"can_upload": true
}],
...more paging JSON information ...}}
我需要能够拉相册信息,以便在列表中显示相册的名称(和使用该ID在另一查询)。有一次,我能拿到专辑展现,然后我会用这些ID来执行另一个查询得到的照片从相册。再次,我还可以得到信息反馈,我只是不知道如何正确地解析它。
I need to be able to pull the album information in order to display the photo album names in a list (and use the ID in another query). Once I can get the albums to show, I would then use those IDs to perform another query to get the photos from that album. Again I can also get that information back, I am just not sure how to properly parse it.
这是有人可能有能够解析为一个ListView这将是极大的AP preciated任何有用的提示。
Any useful tips that someone might have in being able to parse this into a listview would be greatly appreciated.
我需要针对拉出第一ID和专辑名称(ID:从第一次上市假期:3486732467234和名)
I need to target pulling the first ID and the Album name ("id": "3486732467234" and "name": "Vacation" from the first listing)
推荐答案
你为什么不尝试用JSON类...
why don't you try with the json classes...
是这样的:
jsonObject = new JSONObject(your_data);
jArray = jsonObject.getJSONArray("data");
for(int i =0;i<jArray.length();i++){
String name= jArray.getJSONObject(i).getString("name");
String location= jArray.getJSONObject(i).getString("location");
等。
这篇关于如何解析的Facebook数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!