刷新窗口之后,Facebook喜欢 [英] refresh window after facebook like

查看:144
本文介绍了刷新窗口之后,Facebook喜欢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在公司页面中创建了一个应用程序,以添加更多的标签/页面与喜欢门,以确保用户喜欢我们的页面,然后向前推进。如果用户喜欢我们的页面index2.php,那么类似的门就位于一个位于index.php的位置,他们不喜欢我们index1.php是包含的。这一切都正常工作。

I have created an app inside a company page to add more tabs/pages with a "like-gate" to ensure the user likes our page before moving forward. The like gate sits at a location say "index.php" if the user likes our page "index2.php" is included, in they do NOT like us "index1.php" is include instead. This all functions correctly.

我的问题是我想在index1.php(如果他们不喜欢我们)页面中添加一个like按钮。我包括一个允许用户喜欢我们的按钮,但是在点击此按钮之后需要刷新,以便用户可以在同一个门口进行评估,并相应地进行重定向。

My problem is that I would like to include a "like" button inside the "index1.php" (if they dont like us) page. I included a button allowing the user to like us, but need to refresh after this button is clicked so the user can be evaluated at the like-gate again and redirect accordingly.

下面的代码允许用户喜欢但不会按照我的要求进行重定向。我看过fb开发人员页面上的例子,但是对于fb应用程序开发人员来说是新的,并且无法弄清楚我的错误。任何帮助将不胜感激,希望这是足够的信息,但回复如果你需要更多。感谢您的任何帮助,您可以提供。

The code below allows a user to like but does not redirect as I would like it to. I have look at the examples on the fb developer page but am new to fb app dev and cannot figure out my error. Any help would be appreciated, hopefully this is enough information, but reply if you need more. Thanks for any help you can provide.

    <div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
  FB.Event.subscribe('edge.create',
    function() {
        top.window.location = 'http://www.facebook.com/pages/TAG_Communications/122751567742494?sk=app_243094502403141';
        }
    );
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.facebook.com/pages/TAG_Communications/122751567742494" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>


推荐答案

哇,我试图做完全相同事情正在搜索这个在同一时间你发布这个问题!

Wow, I'm trying to do the exact same thing and was searching this at the same time you posted this question! Not much out there on this.

我遇到了 http://www.techjam.gr/2011/web-design/execute-javascript-facebook-button-clicked/ ,这说明了如何运行点击按钮后的回调脚本非常清楚。我看到你已经在做这件事了,但也许有几件事情解释说你没有指定或者没有指定。

I came across http://www.techjam.gr/2011/web-design/execute-javascript-facebook-button-clicked/ which explains what to do to run a callback script after the button is clicked very clearly. I see you already are doing this for the most part, but maybe there are a few pieces explained that you left out or didn't specify.

另外我已经运行很多麻烦尝试重定向父框架,因为它触发跨域javascript访问安全性错误。不知道这是否是您的问题的一部分。对于我自己的案例,我打算只是将iframe页面从no-fan.php重定向到fan.php的点击 - 我不需要重新评估,如果他们是粉丝或不是我的fangate代码,如果他们点击相似的按钮。

Also I've run into a lot of trouble trying to redirect parent frames because it triggers a cross domain javascript access security error. Not sure if that's part of your problem. For my own case I plan to just redirect my iframe page from something like no-fan.php to fan.php on the click - I don't need to re-evaluate if they are a fan or not with my fangate code if they clicked the like button.

希望能帮助您。

更新:

通过上面的链接获得帮助!
这是我做了什么(代码如下):
一定要使用正常的FB.init代码。
将回调脚本与按钮上方的重定向代码相加。
添加类似按钮的xfbml版本。
就是这样!

Got it working with help from the link above! Here's what I did (code below): Be sure to use the normal FB.init code. Add the callback script with the redirect code above the button. Add the xfbml version of the like button. That's it!

请注意,我确实使用了top.window.location,并将其发送到我的fangate评估代码。原因是,如果您只是重定向框架,它会离开页面的其余部分,并且仍然有标题附近的Facebook按钮。刷新整个页面可以让所有的东西看起来应该避免混淆。

Note that I did actually use top.window.location and sent it to my fangate evaluation code anyways. The reason is, if you just redirect the frame it leaves the rest of the page as is , and it still has the facebook like button near the title. Refreshing the whole page gets everything looking the way it should and avoids confusion.

代码:

            <div id="fb-root"></div>
            <script src="http://connect.facebook.net/en_US/all.js"></script>
            <script>
                FB.init({
                    appId :'your id here',
                    status : true, // check login status
                    cookie : true, // enable cookies to allow the server to access the session
                    xfbml : true, // parse XFBML
                    channelUrl : 'full path to file', // channel.html file
                    oauth : true // enable OAuth 2.0
                });
            </script>


        <script>
            FB.Event.subscribe('edge.create', function(href, widget) {
                top.window.location = 'your tab url';
            });
        </script>

        <div id="fb-root"></div>
        <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) {return;}
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>

        <div class="fb-like"><fb:like href="your page you want to like" send="false" layout="button_count" width="200" show_faces="false"></fb:like></div>

这篇关于刷新窗口之后,Facebook喜欢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆