We implemented the buddy list by using the SmartFoxServer's buddy feature in a previous chapter. Users add those buddies when they meet each other inside the virtual world.
Thanks to the integration of the Facebook, we can get the friends list of the players and add them into the buddy list automatically. We create two tabs in the buddy list panel, one tab of the original buddy list and the other tab for the friends list from Facebook.
Similar to the getInfo
command, we create a new FacebookCall
to call the friend list.
var fbcall:FacebookCall = FacebookClient.fb.post(new GetFriends()); fbcall.addEventListener(FacebookEvent.COMPLETE, onFriendsLoad); FacebookClient.fb.post(fbcall);
The friend list returns the user IDs of the friends and we need to fetch the name from the user IDs.
private function onFriendsLoad(e:FacebookEvent):void { e.target.removeEventListener(FacebookEvent.COMPLETE, onFriendsLoad); if (e.success){ var friends:Array = (e.data as GetFriendsData...