Thursday, 7 August 2014

how to get the facebook friend albums in android ?

public static String getFacebookFriendList(String token, Context context,
String fb_id) {
InputStream is = null;
String result = "";

try {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(
"https://graph.facebook.com/"
+ fb_id
+ "?fields=albums.limit(5).fields(id,name,cover_photo,photos.limit(10).fields(name,picture,source))&access_token="
+ token);

System.out
.println("Data"
+ "https://graph.facebook.com/"
+ fb_id
+ "?fields=albums.limit(5).fields(id,name,cover_photo,photos.limit(10).fields(name,picture,source))&access_token="
+ token);
HttpResponse response = httpclient.execute(httpGet);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
e.printStackTrace();
}
// convert response to string
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
Log.i("RESULT", result);
} catch (Exception e) {
e.printStackTrace();
}

return result;
}

No comments:

Post a Comment