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.