使用getFriends()方法。
fb.getFriends();
fb.addEventListener(ResFriendsEvent.RESULT, onFriendsRESULT);
fb.addEventListener(ResFriendsEvent.ERROR, onERROR);
//取得好友列表
private function onFriendsRESULT(e:ResFriendsEvent):void
{
for each (var _friend:Friend in e.friends.list)
{
//好友名
cont.text += _friend.name+"\n";
//好友uid
cont.text += _friend.uid+"\n";
//好友大頭照路徑
cont.text += _friend.headImage()+"\n";
}
}
}
//取得失敗
private function onERROR(e:FaceBook_Event):void
{
cont.text += e.error_msg + "\n";
cont.text += e.failJSON + "\n";
}
使用getFriends()方法取得好友名單,成功回傳ResFriendsEvent.RESULT事件,失敗回傳ResFriendsEvent.ERROR事件。
ResFriendsEvent.RESULT回傳後你可以直接取得事件的friends.list屬性,他是Friend的物件陣列,每個Friend的物件就是一好友資料,你可以取得以下屬性。
_friend.name 名稱
_friend.uid UID
_friend.headImage() 大頭照片路徑
headImage()可以傳入 0~2 的參數,代表回傳的照片大小(0 small 1 normal 2 large)
AS3 Class 懶人系列 之 阿Cain的 FaceBook API 2.0 讓你快速上手FB活動(四) -發布訊息
2 則留言:
請問你的swc怎麼用?我下載了,但完全不能用吶@@
恩?是不能用還是不會用,其實關於swc的用法,你可以去自己去Google大神那查一下囉XD
張貼留言