1

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 ?

Sunil Sunny
  • 3,949
  • 4
  • 23
  • 53
Mahesh
  • 31
  • 5
  • Do you registred your app in facebook console? – Ami Hollander Jul 04 '16 at 09:18
  • Yes , It is a registered app. – Mahesh Jul 04 '16 at 09:20
  • Are you sure you are using the search request as it should be done? https://developers.facebook.com/docs/graph-api/using-graph-api/#search It doesn't look as if there was a "topic" type. – ig343 Jul 04 '16 at 09:34
  • Also. Is your Facebook App set to published in the developers console? There is also an option which says "require app secret" in the settings panel. Have you checked this? – ig343 Jul 04 '16 at 09:41
  • Your app is marked as 'Native / Desktop' ?It can sometimes cause this issue. – Sunil Sunny Jul 04 '16 at 10:37
  • type=topic is not a valid search type. https://developers.facebook.com/docs/graph-api/using-graph-api/#search – CBroe Jul 04 '16 at 11:31
  • @CBroe can you help with this similar question: https://stackoverflow.com/q/45828963/6144372 Please? – Hammad Nasir Aug 23 '17 at 01:10

1 Answers1

0
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());