如何在AS3的Facebook应用程序中邀请朋友

时间:2012-02-09 14:45:30

标签: facebook flash actionscript-3 facebook-graph-api

我正在制作Facebook应用程序(Flash),我必须邀请朋友。我到达的每个地方都找到了这段代码,但不适合我,因为result.request_ids为空。我需要知道用户邀请了多少朋友!请帮忙!!!

代码:

private function inviteFriends():void{
var dat:Object = new Object();
dat.message = "Let's invite friends for our Super Extra Max Facebook App, more info go to http://blog.ukasz.com";
dat.title   = 'Super Extra Max Facebook App';
// filtering for non app users only
dat.filters = ['app_non_users'];
//You can use these two options for diasplaying friends invitation window 'iframe' 'popup'
Facebook.ui('apprequests', dat, onUICallback, 'popup');

}

private function onUICallback(result:Object):void{
if(result == null){
     trace('User closed the pop up window without inviting any friends');
     return
}
var invitedUsers:Array  = new Array();
invitedUsers = result.request_ids as Array;
trace('You Have Invited ', invitedUsers.length,' friends');
//Simple if else if you want user to invite certain amount of friends
if(invitedUsers.length > 1){
    trace('GREAT, USER IS GENERATING TRAFFIC');
}else{
    trace('No Good, User invited only one friend.');
}

}

1 个答案:

答案 0 :(得分:0)

function invite(evt:MouseEvent):void
    {
        var obj:Object = 
        {
            message: "",
            title: ""
        };
        Facebook.ui("apprequests", obj, cbi, "iframe");
    }

function cbi(res):void
    { 
        field_txt.appendText(res.request_ids);
    }