Search code examples
androidfacebook-graph-apirequestfacebook-android-sdkfacebook-requests

Facebook API User Request graphObject is null


So I have an application that is currently using the facebook api to get a users info from facebook. The application has been working 100% until today when suddenly, certain info wouldnt load. I traced it back to the Facebook me request foor getting into from the current user. This is the Log of the request:

{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[{}]}

The graph object is null and the onCompleted method is never called. As I stated before, this has been working great up until now and I have not touched this class at all. The entire request is below, and any help is GREATLY appreciated!

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

Solution

  • Use this library when you deal with Facebook API.because it is AWESOME!! Really!..

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

    Read the docs and enjoy the library.

    Tell me if it helps