2011-12-12 71 views

回答

2

是的,你可以前<body>添加通过添加JS API,

做到这一点:

<script type="text/javascript"> 
    function inviteFriends(){ 
     var receiverUserIds = FB.ui({ 
       method : 'apprequests', 
       message: 'YOUR CUSTOM MESSAGE', 
     }, 
     function(receiverUserIds) { 
        console.log("IDS : " + receiverUserIds.request_ids); 
       } 
     ); 
    } 
</script> 

<body>之后包括API(异步方法):

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId : 'YOUR APP ID', 
     status : true, // check login status 
     cookie : true, // enable cookies to allow the server to access the session 
     xfbml : true, // parse XFBML 
     oauth : true //enables OAuth 2.0 
    }); 
    }; 

    (function() { 
    var e = document.createElement('script'); 
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
    e.async = true; 
    document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 

并调用它:

<a href="#" onclick="inviteFriends(); return false;"></a> 

<a href="javascript:inviteFriends(); return false;"></a> 
0

这是可能的,因为其他的答案都示出,但用户在接受请求时将被带到您的画布应用程序