Facebook API用户请求graphObject为null

时间:2015-02-24 20:06:02

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

所以我有一个应用程序正在使用facebook api从facebook获取用户信息。应用程序一直工作到100%,直到今天突然,某些信息无法加载。我追溯到Facebook请求从当前用户进入。这是请求的日志:

{Request:  session: {Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[user_birthday, basic_info]}, appId:349620835240734}, graphPath: me, graphObject: null, httpMethod: GET, parameters: Bundle[{}]}

图形对象为null,永远不会调用onCompleted方法。正如我之前所说的那样,到目前为止,这一直很好用,我根本没有触及过这个课程。整个请求如下,任何帮助都非常感谢!

Request request = Request.newMeRequest(mSession, new  Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser user, Response response) {
                    // If the response is successful
                    if (mSession == Session.getActiveSession()) {
                        if (user != null) {
                            String currentUserId = user.getId();
                            String name = user.getFirstName();
                            String birthday = user.getBirthday();
                            String age = getAge(birthday);
                            String gender = user.asMap().get(Constants.GENDER).toString();

                            mParseUser.put(Constants.NAME, name);
                            mParseUser.put(Constants.AGE, age);
                            mParseUser.put(Constants.GENDER, gender);
                            mParseUser.saveInBackground();

                            SharedPreferences pref =
                                    mContext.getSharedPreferences(ParseUser.getCurrentUser().getUsername(),
                                            Context.MODE_PRIVATE);
                            SharedPreferences.Editor ed = pref.edit();
                            ed.putString(Constants.FACEBOOK_USER_ID, currentUserId);
                            ed.apply();
                        }
                    }
                }
            });
            Request.executeBatchAsync(request);
            Log.e("RequestValue", String.valueOf(request));

1 个答案:

答案 0 :(得分:0)

在处理Facebook API时使用此库。因为它真棒!真的!..

https://github.com/sromku/android-simple-facebook

阅读文档并享受图书馆。

告诉我它是否有帮助