-
Notifications
You must be signed in to change notification settings - Fork 349
Get profile
Facebook doesn't reveal all user fields by default. For example, if you need picture, then you need to specify it in your graph api request.
I can understand this, since getting all possible user fields will be time consuming task and this is not what we want.
Thus, two options are possible to get profile data.
By using this way, you can get many properties like: id, name, education and more. Just ensure to have needed permissions. Read the javadoc to know what is needed. But, here you won't be able to get several properties like: cover, picture and other.
Initialize callback listener:
OnProfileListener onProfileListener = new OnProfileListener() {
@Override
public void onComplete(Profile profile) {
Log.i(TAG, "My profile id = " + profile.getId());
}
/*
* You can override other methods here:
* onThinking(), onFail(String reason), onException(Throwable throwable)
*/
};
Get the profile:
mSimpleFacebook.getProfile(onProfileListener);
By using this option, you define the properties you need, and you will get only them. Here, any property is possible to get.
Prepare the properties that you need:
Profile.Properties properties = new Profile.Properties.Builder()
.add(Profile.Properties.ID)
.add(Profile.Properties.FIRST_NAME)
.add(Profile.Properties.COVER)
.add(Profile.Properties.WORK)
.add(Profile.Properties.EDUCATION)
.add(Profile.Properties.PICTURE)
.build();
Get the profile:
mSimpleFacebook.getProfile(properties, onProfileListener);
You can describe the picture you really need like: small
, normal
, large
, square
and set width and height.
Prepare specific picture that you need:
PictureAttributes pictureAttributes = Attributes.createPictureAttributes();
pictureAttributes.setHeight(500);
pictureAttributes.setWidth(500);
pictureAttributes.setType(PictureType.SQUARE);
Prepare the properties that you need:
Profile.Properties properties = new Profile.Properties.Builder()
.add(Properties.ID)
.add(Properties.FIRST_NAME)
.add(Properties.PICTURE, pictureAttributes)
.build();
Get the profile:
mSimpleFacebook.getProfile(properties, onProfileListener);
-
Setup
-
Login/Logout
-
Publish
-
Requests/Invite
-
Get 🔻
-
Additional options
-
Samples