Skip to content

Instantly share code, notes, and snippets.

@oparrish
oparrish / gist:1092990
Created July 19, 2011 16:31
Downloading Facebook profile picture
private static final String PROFILE_PICTURE_URL = "https://graph.facebook.com/%s/picture?type=large&access_token=%s";
private String downloadFacebookProfilePicture(String uid, String accessToken, String username) throws MalformedURLException, IOException {
//Get the picture url
HttpURLConnection.setFollowRedirects(false);
String profilePictureUrlString = new URL(String.format(PROFILE_PICTURE_URL, uid, accessToken)).openConnection().getHeaderField(
"location");
//Set up temp location for picture
String fileExtension = StringUtils.substring(profilePictureUrlString,