2013-08-01 32 views
1

我正在做這個facebook邀請(apprequest),但我需要統計用戶發出的邀請數量,任何人都可以幫助我?Facebook應用程序 - 我如何計算髮件人邀請的朋友數量?

以下作品中的代碼,但它只能算作一次邀請不管有多少邀請用戶發送

<script> 
    FB.init({ 
     appId:'<?=$myappid?>', 
     cookie:true, 
     status:true, 
     xfbml:true 
    }); 

    function FacebookInviteFriends() 
    {//start of FacebookInviteFriends 
     var inviteCounter = FB.ui({ 
      method: 'apprequests', 
      message: '<?=$me['name']?> has invited you to play this game!', 
      title: 'Select your friends to play this game!', 
      exclude_ids: <?=$allFBStr?>, 
      max_recipients: 5 
     }, 
      function (inviteCounter) { 

       var userID = '<?=$me['id']?>'; 
       //alert(userID); 
       $.ajax({//ajax 
        type: 'POST', 
        url: 'addInvitationCounter.php', 
        data: { 
         userID: userID 
        }, 
        success: function(result){ 
         //alert("SUCCESS: " + result); 
         location.href = "myprofile.php"; 
        }, 
        error: function(result){ 
         alert("ERROR: " + result); 
        } 
       }); 
      } 
     ); 
    } 


</script> 

回答

1

我不知道如果我得到你的問題的權利,但其實這是對Facebook的政策。

每節V.1。

您不得激勵用戶授予其他權限或使用 應用程序集成點。

而且,約每應用集成的文檔點

通過「應用集成點」是指應用信息部分, 應用程序選項卡,飼料,請求(包括邀請),出版商,收件箱 附件,聊天,書籤或用戶檔案 或Facebook通信頻道的任何其他特徵,其中或通過該通信頻道 應用程序可以提供,顯示或傳遞以 爲代表或由用戶許可的內容。

+0

激勵用戶意味着在現實生活中還是在遊戲中?因爲對於他們在遊戲中所做的每一個邀請,玩家將能夠獲得5分 – Raynoro

+0

它明確表示_「請求(包括邀請)」 - 在Ronny引用的內容中。並獎勵用戶發送邀請(邀請其他不使用應用的用戶/玩遊戲)會產生煩人的垃圾郵件 - 所以請不要這樣做。尋找其他方式來推廣你的遊戲。 – CBroe

+0

Ronny和CBroe,感謝您的回覆,我將重新考慮爲我的項目實施其他功能:) – Raynoro

0

我曾經寫過一個應用程序,根據你邀請的人數來獲得獎金,所以這是可能的。我想你錯過了響應對象的結構。

當我運行類似這樣的邀請碼:

FB.ui({ 
    method: 'apprequests', 
    message: 'XYZ has invited you to play this game!', 
    title: 'Select your friends to play this game!' 
}, function (response) { 
    console.log(response); 
}); 

這是response樣子(ID被改變,見XYZ)

{ 
    request: "634814526537XYZ", 
    to: [ 
    0: "100000526972XYZ" 
    1: "100000756092XYZ" 
    ] 
} 

所以總是有兩個條目在響應對象中,其中一個是'to',一個包含受邀ID的數組。邀請人的數量訪問這樣的:

FB.ui({ 
    method: 'apprequests', 
    message: 'XYZ has invited you to play this game!', 
    title: 'Select your friends to play this game!' 
}, function (response) { 
    var numberOfInvites = response.to.length; 
    alert('You have invited '+ numberOfInvites +'People'); 
}); 

但我不知道這允許任何政策的,所以這就是你應該閱讀有關的話題。

相關問題