skip to Main Content

STORY

I have an app on playstore that downloads the cover photo of the user and sets as the backgound of the drawer.

What Happend?

It stopped working i was using the link below it was working like a charm, but it’s not working anymore, now i only get the id of the user but no cover

What was working before ?

https://graph.facebook.com/{my id}?fields=cover&access_token={my token}

Troubleshoot

I thought that maybe was something that i did without noticing in my code, so downloaded my app from the playstore and i got the same problem the cover is not being downloded so at this point im almost sure that the problem is something to do with facebook itself

I belive is something to do with permissions because i get a responce but not the source of the cover but if it was working with my user i don’t know why isn’t this working anymore

Failed Attemps to fix the problem

I went to Facebook Developers page and i tried this

new GraphRequest(
AccessToken.getCurrentAccessToken(),
"...?fields=cover", 
null,
HttpMethod.GET,
new GraphRequest.Callback() {
    public void onCompleted(GraphResponse response) {
        Log.d(TAG, response.toString());
    }
}
).executeAsync();

Sadly this didn’t work, in facebook developers page they show this "...?fields={fieldname_of_type_CoverPhoto}" i belive fieldname coverPhoto is cover like i see here

Result

This will log

{Response:  responseCode: 404, graphObject: null, error:
{HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) 
Some of the aliases you requested do not exist: ...}}

I tried to remove the 3 dots and i tried to add me?fields=cover got this:

{Response:  responseCode: 404, graphObject: null, error:
{HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) 
Some of the aliases you requested do not exist: fields=cover}}

EDIT

I tried this

Bundle params = new Bundle();
params.putString("fields", "id,email,gender,cover,picture.type(large)");
new GraphRequest(AccessToken.getCurrentAccessToken(), "me", params, HttpMethod.GET,
          new GraphRequest.Callback() {
          @Override
          public void onCompleted(GraphResponse response) {
               if (response != null) {
                  try {
                     JSONObject data = response.getJSONObject();
                     Log.d(TAG, data.toString());
                  } catch (Exception e) {
                      e.printStackTrace();
                      Log.d(TAG, "ERROR");
                }
           }
        }
  }).executeAsync();

this prints all my information but no cover

2

Answers


  1. Chosen as BEST ANSWER

    I was able to fix this issue

    It seems that now we need to use user_photos permission, i belive this was something changed recently because my app was on the playstore for almost a month working perfectly without user_photos

    Remeber that you need to request a new permisson, you can do that with this

    if(!AccessToken.getCurrentAccessToken().getPermissions().contains("user_photos")) {
         LoginManager.getInstance().logInWithReadPermissions(
         this,
         Arrays.asList("user_photos"));
    }
    

  2. Earlier in Facebooks API, it was possible to get the cover photo of a user when accessing graph API, by adding “cover” as a value to the GET parameter “fields” as you were doing (?fields=cover). This were previously valid.

    However Facebook replaced “cover” with “UserCoverPhoto” and then finally removed the possibility to retrieve the cover photo from the user API version 3.2 as seen in the following official link:
    https://developers.facebook.com/docs/graph-api/reference/v3.2/user
    3.2 facebook api

    Even the oldest allowed facebook API version 2.8 does not have this feature.

    Sadly you have to build another solution.

    You would have to use the “user/photos” API and then allowing them to select what photo to use as a cover in your application.
    https://developers.facebook.com/docs/graph-api/reference/user/photos/

    A non-recommended solution and probably against TOS and will get you banned would be to build a solution around the API for non-private users.

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