Bryanzpope
Bryanzpope

Reputation: 1007

Android Getting Facebook Mutual Friends How To Fill In USER ID?

I'm trying to update my app to the new way to getting mutual friends from the facebook graph API v2.0.

On thier website here: https://developers.facebook.com/docs/graph-api/reference/v2.0/user.context/mutual_friends

they recommend to use this code:

 Bundle params = new Bundle();
params.putString("fields", "context.fields(mutual_friends)");
 /* make the API call */
new Request(
session,
"/{user-id}",
params,
HttpMethod.GET,
new Request.Callback() {
    public void onCompleted(Response response) {
        /* handle the result */
    }
}
).executeAsync();

So I edited this code to put in the USER ID like so....

    Bundle params = new Bundle();
                    params.putString("fields", "context.fields(mutual_friends)");
                    // make the API call
                    new Request(Session.getActiveSession(), "/{" + userProfile.getString("facebookId") + "}", params, HttpMethod.GET,
                            new Request.Callback() {
                                public void onCompleted(Response response) {
                                    /* handle the result */
                                    System.out.println(response.toString());
                                }
                            }).executeAsync();

When I run the code, I get this error:

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

This alias does exist. What is wrong with my request?

Upvotes: 1

Views: 732

Answers (1)

phwd
phwd

Reputation: 19995

The error response explains it

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

This alias {10102533400666784} does not exist remove the {}

Upvotes: 2

Related Questions