繁体   English   中英

在Facebook Page选项卡中使用JavaScript SDK时出现FB.login错误

[英]FB.login error when using JavaScript SDK inside a Facebook Page tab

我正在尝试在页面标签应用程序内使用JavaScript SDK(出于共享目的而不是其他目的)。

我在FB.init之后调用FB.login,但在弹出窗口中收到此错误: “发生错误。请稍后重试。”

Facebook OAuth错误

这在开发中和部署到Heroku时都会发生(这是Rails 3应用程序)。

您可以在此处看到样本/演示 ,但是这里是相关代码:

<body>
    <div id='fb-root'></div>

    <div id='welcome_header'>
      <h1>Coupons</h1>
    </div>
    <h2>Sorry, no active coupons at this time.</h2>
    <h3>
      Sign up to receive future coupons from
      Ed's Coffee &amp; Deli
    </h3>
    <div id='form_section'>
      <form accept-charset="UTF-8" action="/fb/1/subscribers" class="new_subscriber" data-remote="true" id="new_subscriber" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="W3tWnguGrIMRJVXh23K6jTxmOH+QbeJZSD5CUnGf7bg=" /></div>
        <input id="subscriber_email" name="subscriber[email]" placeholder="enter email" size="30" type="text" />
        <input class="btn small btn-primary" name="commit" type="submit" value="GO" />
      </form>
    </div>
    <script>
      //<![CDATA[
        window.fbAsyncInit = function() {
          FB.init({
            appId      : '179754758810880', // App ID
            channelUrl : '//localhost:5000/channel.html', // Channel File
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            oauth      : true  // parse XFBML
          });    
          // Login
          FB.login(
            function(response) {
              console.log(response);
            },
            { scope: 'publish_actions' }
          );
        };
        // Load the SDK Asynchronously
        (function(d){
           var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
           if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           ref.parentNode.insertBefore(js, ref);
         }(document));
      //]]>
    </script>
  </body>

知道为什么会这样吗? 可以在页面标签内使用JS SDK吗?

不喜欢回答我自己的问题,但是我能够解决这个问题。

在应用设置中,我没有在集成选项下选中“网站”。 我以为是因为它被设置为页面选项卡,所以没有必要。 但它是。

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM