Twitter - 无法在Android中获得关注者列表

时间:2017-12-26 05:38:55

标签: android twitter

在我的应用中集成twitter,当用户通过twitter登录时,我会显示发送消息的关注者列表,但在调用/1.1/followers/list.json API时,我得到了空响应,我需要permission才能访问API吗?

{protocol=h2, code=400, message=, url=https://api.twitter.com/1.1/followers/list.json?screen_name=(screenname)&cursor=-1&skip_status=true}



 loginButton.setCallback(new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {
            e("********", "----result--->>>>" + result.response);

          /*  TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
            TwitterAuthToken authToken = session.getAuthToken();
            String token = authToken.token;
            String secret = authToken.secret; */

        /***********************After login****************/

            APIService inf1 = MyApplication.getRetro(Login.this, "https://api.twitter.com").create(APIService.class);
            final Call<JsonElement> res1 = inf1.show("-1","(screenName)",true,false);
           // "/1.1/followers/list.json?include_user_entities=false&screen_name=twitterdev&skip_status=true&cursor=-1
            res1.enqueue(new retrofit2.Callback<JsonElement>() {
                @Override
                public void onResponse(@NonNull Call<JsonElement> call, @NonNull Response<JsonElement> response) {


                    try {
                        JSONObject mReturn = new JSONObject(response.body().toString());

                        e("-------->>", "*******onResponse*******"+mReturn);


                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {


                }
            });
      /************************************************/


        }

        @Override
        public void failure(TwitterException exception) {
            // Do something on failure
        }
    });

API:

@GET("/1.1/followers/list.json")
Call<JsonElement> show( @Query("cursor")String cursor,
                        @Query("screen_name")String var,

                       @Query("skip_status")boolean skip_status,
                       @Query("include_user_entities")boolean include_user_entities);

0 个答案:

没有答案