我该如何从Facebook获取用户的所有照片集?我尝试了以下方式使用此URL:
我遇到了这个错误:
https://graph.facebook.com/me/albums?access_token=xxxx
我正在使用此代码,并已提及这些权限:"user_photos"
。Bundle parameters = new Bundle();
parameters.putString("format", "json");
parameters.putString("method", "user_photos");
parameters.putString(TOKEN, facebook.getAccessToken());
JSONObject response = null;
try {
response = Util.parseJson(Album_Url);
JSONArray array = obj.optJSONArray("data");
for(int i = 0; i<array.length(); i++){
JSONObject main_obj = array.getJSONObject(i);
String album = main_obj.getString("name");
}
} catch (JSONException e1) {
e1.printStackTrace();
} catch (FacebookError e1) {
e1.printStackTrace();
}
但是我在日志中看到了以下信息:09-12 14:27:42.990: W/System.err(12189): org.json.JSONException: Value https of type java.lang.String cannot be converted to JSONObject
我也尝试过这样做:
try {
Bundle parameters = new Bundle();
parameters.putString("format", "json");
parameters.putString(TOKEN, facebook.getAccessToken()) ;
String response = null;
try {
response = Util.openUrl(Album_Url, "GET", parameters);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
JSONObject obj = Util.parseJson(response);
JSONArray array = obj.optJSONArray("data");
for(int i = 0; i<array.length(); i++){
JSONObject main_obj = array.getJSONObject(i);
String album = main_obj.getString("name");
}
} catch (JSONException e1) {
e1.printStackTrace();
} catch (FacebookError e1) {
e1.printStackTrace();
}
我遇到了这个错误:
09-12 14:42:36.920: W/System.err(12259): com.facebook.android.FacebookError: Malformed access token
。