Mahesh
Mahesh

Reputation: 31

Facebook search from android

I was trying to send a search query to facebook using facebook android sdk according to their reference. However, the Graph request is rejected by the following response.

    Code:
    LoginManager.getInstance().registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    Bundle params = new Bundle();
                    params.putString("type", "topic");
                    params.putString("q", "Johny");
                    params.putString("fields", "id,name,page");

                    new GraphRequest(
                            AccessToken.getCurrentAccessToken(),
                            "/search",
                            params,
                            HttpMethod.GET,
                            new GraphRequest.Callback() {
                                public void onCompleted(GraphResponse response) {

                                    System.out.println(response.toString());
                                }
                            }
                    ).executeAsync();
                }

Response: {Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 15, errorType: OAuthException, errorMessage: (#15) This method must be called with an app access_token.}}

Does anyone facing the same issue with Android SDK by facebook ?

Upvotes: 1

Views: 133

Answers (1)

Craig A. Willhite
Craig A. Willhite

Reputation: 1

Code:
LoginManager.getInstance().registerCallback(callbackManager,
        new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                Bundle params = new Bundle();
                params.putString("type", "topic");
                params.putString("q", "Johny");
                params.putString("fields", "id,name,page");

                new GraphRequest(
                        AccessToken.getCurrentAccessToken(),
                        "/search",
                        params,
                        HttpMethod.GET,
                        new GraphRequest.Callback() {
                            public void onCompleted(GraphResponse response) {

                                System.out.println(response.toString());

Upvotes: 0

Related Questions