Last active
September 15, 2015 20:55
-
-
Save lmedinas/d62450ac0a98d0b9555b to your computer and use it in GitHub Desktop.
Get facebook albums URL using Android SDK 4.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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