2013-10-30 47 views
-5

我已经实施了来自facebook-invite-friends-api的Facebook邀请函,但我无法获得他们如何重定向到我的网站,因为他们(9lesson)已从facebook通知中演示。 请帮我,我该怎么做。如何从Facebook应用重定向到我的网站?

我的代码是:

<div id="fb-root"> 
</div> 
<a href="javascript:void(0);" 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: '******', 
      session: {}, 
      status: true, 
      cookie: true, 
      xfbml: true 

     }); 
    }; 

</script> 

我的登录页面代码:

<script type='text/javascript'> 
    if (top.location != self.location) { 
     top.location = self.location 
    } 
</script> 

回答

3

基本上,当上了邀请一个用户点击,它们被发送到你的应用程序的画布URL。您在应用程序设置中设置的那个。

用户将被发送到你的应用程序,并从那里你可以使用JavaScript重定向,因为他们在本教程你链接到他们重定向到您的实际网站:

下面的代码被打破的iFrame ,请将此代码包含到您的网页中。

<script type='text/javascript'> 
if (top.location!= self.location) 
{ 
top.location = self.location 
} 
</script> 

当他们说“分手的iframe”他们的意思是采取含量超出了iframe的,进入它的实际URL(愚蠢的字眼......我同意)。请注意使用top.location。这将改变最顶部框架的位置 - 在这种情况下,它是apps.facebook.com

+0

我在登录页面中添加了上面的代码,但我无法获得所需的结果... –

+0

控制台中是否存在任何JS错误?用户是否真的到达了登录页面? – Lix

+0

我已经使用警报检查,但它甚至是火警....所以我不能说它到达登录页面..但我已将其设置为我的网站的默认页面。并输入画布网址:: http://subdomain.domian.com/foldername/ –

相关问题