skip to Main Content

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”:”����u0000u0010JFIFu0000u0001u0002u0000u0000u0001u0000u0001u0000u0000��u0000�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;

3

Answers


  1. Chosen as BEST ANSWER

    Solved. I use my method with some change. Add this parameter

            Bundle params = new Bundle();
            params.putBoolean("redirect", false);
    

    Thanks for inspiration.


  2. 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();
    
    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search