繁体   English   中英

朋友喜欢不使用Android的Graph API

[英]Friend likes not coming in Graph API in Android

我试图通过Android应用程序来获得图API中的朋友喜欢。 我无需指定字段属性就可以获取朋友的ID,姓名。 (例如“ /我/朋友”)

Session.openActiveSession(this, true, new Session.StatusCallback() {

            @Override
            public void call(Session session, SessionState state,
                    Exception exception) {
                // TODO Auto-generated method stub
                Log.d("zumbvare", session.getPermissions().toString());

                if (session.isOpened()){

                    Request.newMeRequest(session, new Request.GraphUserCallback() {

                        // callback after Graph API response with user object
                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                          if (user != null) {


                            /*TextView welcome = (TextView) findViewById(R.id.welcome);
                            welcome.setText("Hello " + user.getName() + "!");*/
                          }
                        }
                      }).executeAsync();

                    new Request(
                            session,
                            "/me/friends",
                            null,
                            HttpMethod.GET,
                            new Request.Callback() {
                                public void onCompleted(Response response) {
                                    /* handle the result */

                                    Log.d("Zumbare", response.toString());
                                    fbResponse=response.toString();
                                    GraphObject graphObject = response.getGraphObject();
                                    if (graphObject != null){
                                        JSONObject jsonObject = graphObject.getInnerJSONObject();
                                        try{
                                            JSONArray array = jsonObject.getJSONArray("data");
                                            Friend f;
                                            for (int i = 0; i < array.length(); i++) {

                                                f= new Friend();
                                                 JSONObject object = (JSONObject) array.get(i);
                                                 Log.d("Zumbare", "id = "+object.get("id"));
                                                 f.setID(String.valueOf(object.get("id")));
                                                 Log.d("Zumbare", "id = "+object.get("name"));
                                                 f.setName(String.valueOf(object.get("name")));
                                                 /*JSONArray a = object.getJSONArray("likes");
                                                 Log.d("Zumbare", "likes count : "+a.length());
                                                 f.setLikes(String.valueOf(a.length()));*/
                                                 friendList.add(f);

                                              }
                                            Log.d("Zumbare", "Friend list count : "+friendList.size());
                                        }catch (JSONException e) {

                                            e.printStackTrace();
                                           }
                                    }
                                }
                            }
                        ).executeAsync();
                }






            }




        });

但是,如果我将字段属性添加为“ / me / friends?fields = id,name,likes”,则会出现异常

{Response:  responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 2500, errorType: OAuthException, errorMessage: An active access token must be used to query information about the current user.}, isFromCache:false}

我可以得到权限字符串日志为

[public_profile, basic_info, user_relationships, user_location, user_likes, user_activities, user_friends, user_about_me, user_status, user_tagged_places]

那么有人可以帮助我如何获得朋友的喜欢吗?

TIA

您只能检索在应用程序中也已授予user_likes权限的朋友的喜欢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM