Facebook从android搜索

时间:2016-07-04 09:13:58

标签: android facebook facebook-graph-api facebook-android-sdk

我试图根据他们的参考使用facebook android sdk向facebook发送搜索查询。但是,Graph请求被以下响应拒绝。

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

响应:{响应:responseCode:400,graphObject:null,错误:   {HttpStatus:400,errorCode:15,errorType:OAuthException,   errorMessage:(#15)必须使用app调用此方法   的access_token。}}

Facebook是否有人面临与Android SDK相同的问题?

1 个答案:

答案 0 :(得分: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());