2013-10-11 84 views
0

我使用下面的代碼來發送邀請到我的Facebook的朋友,但它打開請求彈出,但沒有邀請被接受我的朋友:無法從我的網站向Facebook好友發送邀請?

<div> 
    <div id="fb-root"> 
    </div> 
    <script src="http://connect.facebook.net/en_US/all.js"> 

如果(!top.location = self.location){ top.location = self.location }

 FB.init({ 
      appId: 'my_app_id', 
      cookie: true, 
      status: true, 
      xfbml: true 
     }); 

     function FacebookInviteFriends() { 
      FB.ui({ 
       method: 'apprequests', 
       message: '9lessons Programming Blog Topics focused on Web Programming.' 
      }); 
     } 
    </script> 
    <a href='#' onclick="FacebookInviteFriends();">Facebook Invite Friends</a> 
</div> 

我下面的This link to to do this.

請幫助我。請幫助我找到我在做錯的地方。 這是我的應用程序設置的屏幕截圖enter image description here

+0

你有在Facebook上設置的畫布應用程序嗎? – CBroe

+0

@CBroe我添加了應用程序的屏幕截圖 –

+0

將您的應用程序移出沙盒模式... – CBroe

回答

0

我沒有做任何事情,只是「把我的應用程序退出沙盒模式」並在Live網站上上傳頁面。它在那裏工作得很好。我認爲Facebook無法從本地主機發送邀請。所以這裏是我用來發送從Facebook的邀請代碼。:

<div id="fb-root"> 
</div> 
<a href="#" onclick="FbRequest('If you want to fulfill your wishes then do not miss the opertuanty, huury up and join WishIsDone, A platform where you can fulfill your as well as your friends wishes...!','609416079110673');"> 
    Send Request</a> 
<script type="text/javascript"> 
    function FbRequest(message, data) { 
     FB.ui({ method: 'apprequests', message: message, data: data, title: 'Share this site with your friends' }, 
      function (response) { 
       // response.request_ids holds an array of user ids that received the request 
       var receiverIDs; 
       if (response.request) { 
        var receiverIDs = response.to; // receiverIDs is an array holding all user ids 
        alert(receiverIDs); 
       } 
      } 
    ); 
    } 
    // typical application initialization code for your site 
    (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); 
    }()); 
    window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'app_Id', 
      session: {}, 
      status: true, 
      cookie: true, 
      xfbml: true 
     }); 
    }; 
</script> 

這就是全部,並感謝所有誰回答了我的問題。

相關問題