Ash
Ash

Reputation: 2304

Why do profile pic URLs returned from graph.facebook result in a 404

The backend of my application makes a request to:
https://graph.facebook.com/v2.8/me?access_token=<firebase-access-token>&fields=id,name,first_name,birthday,email,picture.type(large){url}&format=json&method=get&pretty=0&suppress_http_code=1

I get a successful (200) response with the JSON data I expect and picture field as such:

"picture": {
    "data": {
        "url": "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=<asid>&height=200&width=200&ext=<ext>&hash=<hash>"
    }
}

(where in place of <asid> and <ext>, there are numbers and <hash> is some alphanumeric string).

However, when I make a GET request to the platform-lookaside URL above, I get a 404 error.

It's been happening every time since my very first graph.facebook request for the same user. The very first one returned a platform-lookaside URL which pointed to a proper image (not sure if this is simply coincidence).

Is there something I'm doing wrong or is this likely a bug with the Facebook API?

Upvotes: 2

Views: 2033

Answers (2)

Ewere Isibor
Ewere Isibor

Reputation: 1

Try this code it worked for me

    GraphRequest request = GraphRequest.newMeRequest(
                AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        // Insert your code here
                        try {
                            String name = object.getString("name");
                            String email = object.getString("email");
                            String last_name = object.getString("last_name");
                            String first_name = object.getString("first_name");
                            String middle_name = object.getString("middle_name");
                            String link = object.getString("link");
                            String picture = object.getJSONObject("picture").getJSONObject("data").getString("url");
                            Log.e("Email = ", " " + email);
                            Log.e("facebookLink = ", " " + link);
                            Log.e("name = ", " " + name);
                            Log.e("last_name = ", " " + last_name);
                            Log.e("first_name = ", " " + first_name);
                            Log.e("middle_name = ", " " + middle_name);
                            Log.e("pictureLink = ", " " + picture);

                        } catch (JSONException e) {
                            e.printStackTrace();
                            Log.e("Sttaaaaaaaaaaaaaaaaa", e.getMessage());
                        }
                    }
                });
        Bundle parameters = new Bundle();
        parameters.putString("fields", "id,name,email,link,last_name,first_name,middle_name,picture");
        request.setParameters(parameters);
        request.executeAsync();
    

Upvotes: -1

lars.schwarz
lars.schwarz

Reputation: 1274

FB currently seems to have issues with some CDNs and therefore your issue might be only temporary. You should also see missing/broken images on some places on fb dot com. Worst time to debug your issue :)

Upvotes: 0

Related Questions