0

我的 restFB 代码导致在一个应用程序上写入我的 ArrayList。我需要 arraylist 正确填写 JSON 中返回的 appIds 的数量。有什么见解吗?

这是我的代码:

public List<String> fetchAppIdsForUser() {
    Connection<FacebookApp> appList = getClient().fetchConnection("me/applications/developer", FacebookApp.class);

    List<String> appIds = new ArrayList<String> ();
    for (List<FacebookApp> appListTwo : appList) {
          for (FacebookApp app : appListTwo) {
            appIds.add(app.getAppId());
          }
    }

    return appIds;
}

以下是 JSON 中返回的内容:

{
   "data": [
      {
         "name": "x",
         "namespace": "x",
         "id": "x"
      },
      {
         "name": "xx",
         "namespace": "xx",
         "id": "xx"
      },
      {
         "name": "xxx",
         "namespace": "xxxx",
         "id": "xxxxx"
      },
      {
         "name": "xxxx",
         "namespace": "xxxxx",
         "id": "xxxxx"
      }
   ],
   "paging": {
      "next": "https://graph.facebook.com/xxxxx/applications?type=developer&format=json&access_token=XXXXXXXX"
   }
}
4

1 回答 1

0

我使用以下方法解决了它:

public List<String> fetchAppIdsForUser() {
    Connection<FacebookApp> appList = getClient().fetchConnection("me/applications/developer", FacebookApp.class);
    List<FacebookApp> list = appList.getData();
    ArrayList<String> appNames = new ArrayList<String>();
    for (FacebookApp app: list) {
        appNames.add(app.getName());
    }       
    return appNames;
}
于 2013-06-30T19:46:35.780 回答