如何使用Facebook Graph API中的GraphRequest从album_id中获取所有相册照片?

时间:2017-07-23 21:36:29

标签: android facebook-graph-api

这是以下代码的JSON格式

"albums": {
"data": [
  {
    "created_time": "2013-06-08T14:43:51+0000",
    "name": "Profile Pictures",
    "id": "1378810178998660"
  }

//代码

GraphRequest request = GraphRequest.newMeRequest(
            loginResult.getAccessToken(),new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object, GraphResponse response) {

                    if(response!=null) {
                        final JSONObject jsonObject = response.getJSONObject();

                        try {

                            final JSONObject json_album = jsonObject.getJSONObject("albums");
                            final JSONArray jarray_album = json_album.getJSONArray("data");
                            final JSONObject j_data = jarray_album.getJSONObject(0);
                            final String id = j_data.getString("id");

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
    Bundle parameters = new Bundle();
    parameters.putString("fields","albums");
    //location,picture,education,hometown,interested_in,political,education,locale,age_range,is_verified,photo,relationship_status
    request.setParameters(parameters);
    request.executeAsync();

所以,我只能获取相册ID,但无法获取与该相册相关的照片。所以,我该怎么办?

1 个答案:

答案 0 :(得分:0)

您应该抓取<album-id>/photos,但我不知道如何使用您正在使用的框架解决此问题。