Capture Facebook Album Cover Photo - Android
I am trying to get album data from facebook and I am using this method to get album artwork. I get a response like this:
{Response: responseCode: 200, graphObject: GraphObject {graphObjectclass = GraphObject, state = {"FACEBOOK_NON_JSON_RESULT": "\ u0000 \ u0010JFIF \ u0000 \ u002 \ u0000 \ u0000 \ u0001 \ u0000 \ u0001 \ u0000 \ u0000 Photoshop"} error: null, isFromCache: false}
What does it mean? How can I get the url of an image or an image? The code is here:
for(final FbAlbumItem f: albums){
Bundle params = new Bundle();
params.putString("type", "small");
new Request(
Session.getActiveSession(),
"/"+f.getAlbumId()+"/picture",
params,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
Log.i("SocialManager", "" + response);
JSONObject obj = response.getGraphObject().getInnerJSONObject();
try {
JSONObject o = obj.getJSONObject("albums").getJSONObject("data");
String url = o.getString("url");
f.setImageUrl(url);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
).executeAsync();
FbAlbumItem:
String albumId;
String albumName;
String albumCover;
String imageUrl;
+3
source to share
3 answers
U could do so.
final Session session = Session.getActiveSession();
if (session.isOpened()) {
final String authToken = session.getAccessToken();
// saveToPreferences(ApplicationData.FB_TOKEN, authToken);
Bundle params = new Bundle();
params.putBoolean("redirect", false);
params.putString("height", "400");
params.putString("type", "normal");
params.putString("width", "400");
/* make the API call */
new Request(
session,
"/me/albums/{album-id}",
params,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
//cover_photo_fetch = response.cover_photo.toString();
Log.d("Picture", response.toString());
try {
userModel = UserModel.getInstance(mContext);
personPhotoUrl = response.getGraphObject().getInnerJSONObject().getJSONObject("data").getString("url");
} catch (JSONException e) {
e.printStackTrace();
}
}
}
).executeAsync();
+1
source to share