Skip to content

Instantly share code, notes, and snippets.

@lmedinas
Last active September 15, 2015 20:55
Show Gist options
  • Save lmedinas/d62450ac0a98d0b9555b to your computer and use it in GitHub Desktop.
Save lmedinas/d62450ac0a98d0b9555b to your computer and use it in GitHub Desktop.
Get facebook albums URL using Android SDK 4.x
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
JSONObject json = response.getJSONObject();
if (json != null) {
String image_path = "https://graph.facebook.com/" + userid + "/picture?type=large";
Log.d(TAG, "image_path: " + image_path);
try {
Log.d(TAG, "User Name: " + object.optString("name"));
path = object.optString("id");
JSONArray subArray = object.getJSONObject("photos").getJSONArray("data");
String link = "";
ArrayList<String> mylist = new ArrayList<String>();
for (int i = 0; i < subArray.length(); i++) {
mylist.add(subArray.getJSONObject(i).getString("source"));
}
Log.d(TAG, "link got: " + mylist.get(1));
image_path = mylist.get(2);
} catch (JSONException e) {
Log.e(TAG, e.toString());
e.printStackTrace();
}
finalimage = getImage(image_path);
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id, name, picture, photos{source}");
request.setParameters(parameters);
request.executeAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment