Skip to main content
Version: 2.x.x

Facebook Friends

Configure

This feature requires Facebook Authorization

Configure Facebook

Usage

To get friends list from Facebook social network you should implement onGetSocialFriendsResult method in Platform101XPListener:

@Override
public void onGetSocialFriendsResult(List<Platform101XPSocialFriend> friendsList, Platform101XPError error) {
if (error != null) { // Error
showMessage(error.toString());
} else { // Success
if (friendsList.isEmpty()) {
showMessage("Friends not found!");
} else {
//Handle friends list result:
StringBuilder friendsNameBuilder = new StringBuilder();
for (Platform101XPSocialFriend friend : friendsList) {
friendsNameBuilder.append(friendsNameBuilder.length() == 0 ? "" : ", ");
friendsNameBuilder.append(friend.getName());
}
showMessage("Friends: " + friendsNameBuilder.toString());
}
}
}

// Kotlin
override fun onGetSocialFriendsResult(friendsList: List<Platform101XPSocialFriend?>?, error: Platform101XPError?) {
if (error != null) {
showMessage("$error")
} else {
friendsList?.let {
if (it.isEmpty()) {
showMessage("Friends not found!")
} else {
val friendsNameBuilder = StringBuilder()
for (friend in friendsList) {
friendsNameBuilder.append(if (friendsNameBuilder.isEmpty()) "" else ", ")
friendsNameBuilder.append("${friend?.name}")
}
showMessage("Friends: $friendsNameBuilder")
}
}
}
}

Platform101XPSocialFriend has getters:

getName() - the friend name

getSocialNetId() - the social network id

getPictureUrl() - the social network picture url

getMobileId() - the 101XP mobile ID

getLevel() - the player game level

To get social friend result you should call method Platform101XP.getSocialFriends() with type Facebook parameter:

// Java
Platform101XP.Companion.getSocialFriends(Platform101XPSNType.FACEBOOK);

// Kotlin
Platform101XP.getSocialFriends(Platform101XPSNType.FACEBOOK)