I try fetch album datas from facebook and i use this method for fetch album cover photo. i get response like this;
{Response: responseCode: 200, graphObject: GraphObject{graphObjectClass=GraphObject, state={"FACEBOOK_NON_JSON_RESULT":" \ \JFIF\ \\\ \ \\ \\ \ \ Photoshop"}}, error: null, isFromCache:false}
What's that's mean ? How can i get image url or image ? 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;
String albumId; String albumName; String albumCover; String imageUrl;
Solved. I use my method with some change. Add this parameter
Bundle params = new Bundle(); params.putBoolean("redirect", false);
Thanks for inspiration.
Prerequisite - user_photos
permission for non public albums
Get it with the cover_photo
field
me/albums/album_id?fields=cover_photo
Doc reference here
U could have done like this.
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.