【问题标题】:How to redirect to my website from facebook app?如何从 facebook 应用程序重定向到我的网站?
【发布时间】:2013-10-30 11:42:26
【问题描述】:

我已经从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>

【问题讨论】:

    标签: facebook facebook-apps facebook-invite


    【解决方案1】:

    基本上,当用户点击其中一个邀请时,它们会被发送到您的应用程序的画布 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

    【讨论】:

    • 我已经在登录页面中添加了上述代码,但我无法获得所需的结果...
    • 你的控制台有 JS 错误吗?用户是否真的到达了登录页面?
    • 我已经使用警报进行检查,但它甚至是火灾警报。所以我不能说它到达登录页面。但我已将其设置为我网站的默认页面。并将画布网址输入为 :: subdomain.domian.com/foldername
    • 如果 Facebook 没有将您发送到正确的登录页面,那么您设置的 url 有错误...请仔细检查画布 url 是否正确...您可以发布画布链接在这里?
    • 它是 "http://" wishisdone.visionswebsites.com/wishisdone/" 我在 // 之后添加了 " 以正确显示网址
    猜你喜欢
    • 2014-10-27
    • 2020-05-17
    • 2021-09-21
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 2018-03-04
    • 2013-01-06
    • 2011-11-20
    相关资源
    最近更新 更多