0

I am working on a login function with facebook for my android app.

I have almost everything done but i can't get all the fields.

Im getting only something in fullname and the fbid.

First name, Gender, Profile picture returns nothing.

  GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject fbUser,
                                                GraphResponse response) {

                            final ParseUser parseUser = ParseUser.getCurrentUser();
                            try{
                                parseUser.fetchIfNeeded();
                            }catch (Exception e){}

                            if (fbUser != null && parseUser != null
                                    && fbUser.optString("name").length() > 0) {
                                Log.d("fb","Json--"+fbUser);
                                parseUser.put(USER_OBJECT_NAME_FIELD, fbUser.optString("first_name"));
                                   parseUser.put("fullname",fbUser.optString("name"));
                            try{
                                   String mm= fbUser.getString("email");
                                    parseUser.setEmail(mm);
                                }catch (Exception e){//e.printStackTrace();
                                  }
                                   try{
                                    String mm= fbUser.getString("gender");
                                    if(mm.equals("male"))
                                    {

For profile pic i'm using this:

          try {
                                    final String id = fbUser.getString("id");
                                    parseUser.put("fbId", id);

                                    //Your code goes here
                                    String ur = "https://graph.facebook.com/" + id + "/picture?width=640&height=640";
                                    ImageLoader imageLoader = ImageLoader.getInstance();
                                    imageLoader.init(ImageLoaderConfiguration.createDefault(getActivity().getApplicationContext()));
                                    imageLoader.loadImage(ur, new SimpleImageLoadingListener() {
                                        @Override
                                        public void onLoadingComplete(String imageUri, View view, Bitmap bmImg) {
                                            // Do whatever you want with Bitmap
                                            if(bmImg!=null) {
                                                bmImg=Bitmap.createScaledBitmap(bmImg,640,640,false);
                                                ParseFile dL = new ParseFile("dpLarge.jpg", bmImg.toString().getBytes());
                                                Bitmap smal = Bitmap.createScaledBitmap(bmImg, 120, 120, false);
                                                ParseFile ds = new ParseFile("dpSmall.jpg", smal.toString().getBytes());
                                                parseUser.put("dpLarge", dL);
                                                parseUser.put("dpSmall", ds);
                                            }

Permissions:

      facebookLoginButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            loadingStart(false); // Facebook login pop-up already has a           spinner
            if (config.isFacebookLoginNeedPublishPermissions()) {
                  ParseFacebookUtils.logInWithPublishPermissionsInBackground(getActivity(),
                        config.getFacebookLoginPermissions(), facebookLoginCallbackV4);
            } else {
                ParseFacebookUtils.logInWithReadPermissionsInBackground(getActivity(),
                        config.getFacebookLoginPermissions(), facebookLoginCallbackV4);
            }
        }
    });
}

Can't figure out what im doing wrong.

v. seckin
  • 1
  • 1
  • What permissions you are requesting? – diogojme Dec 10 '15 at 21:37
  • I have and in the AndroidManifest.xml file – v. seckin Dec 10 '15 at 21:41
  • Sorry, im not talking about the manifest permission, but facebook permissions, Please check this answer -> http://stackoverflow.com/a/32776987/1879661 and make sure your are calling the right permissions like `"public_profile", "user_friends", "email", "user_birthday"`. – diogojme Dec 10 '15 at 22:34

1 Answers1

0

I haven't already used facebook sdk, but according to your problem with a profile picture, did you tried solutions from these posts:

How to get facebook profile picture of user in facebook SDK 3.0 Android

How to get facebook profile picture of user in facebook SDK Android

Try also to use some logs for example to check if String ur appears correctly.

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • Really strange. If you have an facebook account, please join this group (https://www.facebook.com/groups/fbdevelopers/) and there paste this issue – piotrek1543 Dec 10 '15 at 23:04