我已经从facebook-invite-friends-api实现了facebook的邀请框,但我无法了解他们如何重定向到我的网站,因为他们(9lesson)已经在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>
答案 0 :(得分:3)
基本上,当用户点击其中一个邀请时,它们会被发送到您应用程序的画布URL。您在应用程序设置中设置的那个。
用户将被发送到您的应用程序,然后您可以使用JavaScript重定向将其重定向到您的实际网站,就像您在链接到的教程中一样:
以下代码用于打破iframe,请将此代码包含在您的网页中。
<script type='text/javascript'>
if (top.location!= self.location)
{
top.location = self.location
}
</script>
当他们说“打破iframe”时,他们的意思是将内容从iframe中取出并放入其实际网址中(愚蠢的措辞......我同意)。请注意top.location
的使用。这将更改最顶部框架的位置 - 在这种情况下,它是apps.facebook.com
。