无法存储来自Facebook API的数据

时间:2016-03-15 10:14:07

标签: android facebook-graph-api

我必须从Facebook的图形API中检索图像路径。我如何将其存储到我的语言环境存储中?当我在完整方法上使用语言环境存储时,我得到一个空值存储在本地存储上。

private void getPhotoFromId(String photoId) {
        Log.d("Adapter" + "getPhotoFromId:-", photoId + "");
        GraphRequest request = GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken(), "/" + photoId, new GraphRequest.Callback() {
            @Override
            public void onCompleted(GraphResponse response) {
                Log.d("Adapter Photo", response.toString());
                try {
                    JSONObject mObject = new JSONObject(String.valueOf(response.getJSONObject()));
                    JSONArray mArray = mObject.getJSONArray("images");
                    JSONObject imageObject = mArray.getJSONObject(0);
                    source = imageObject.getString("source");
                   prefHelper.savePref(Constants.IMAGE_SOURCE,source);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        Bundle parameters = new Bundle();
        parameters.putString("fields", "images,picture");
        request.setParameters(parameters);
        request.executeAsync();
    }

1 个答案:

答案 0 :(得分:0)

我想你不应该添加" /"在你的身份证明前。
您是否在Facebook Developer网站的Graph API中尝试过这种方法?

https://developers.facebook.com/tools/explorer/145634995501895/

我无法找到这样的字段名称"图片,图片"。