0

当点击like按钮时,我明白了。

不安全的 JavaScript 尝试使用 URL http://www.facebook.com/dialog/oauth?api_key=248753205242460&app_id=248753205242460&channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%访问框架3D9%23cb%3Dfedecb848%26origin%3Dhttp%253A%252F%252Flocalhost%252Ff2ad19772%26domain%3Dlocalhost%26relation%3Dparent.parent&client_id=248753205242460&display=none&domain=localhost&locale=en_US&origin=2F%2Fstatic.facebook.A% com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D9%23cb%3Df99e53428%26origin%3Dhttp%253A%252F%252Flocalhost%252Ff2ad19772%26domain%3Dlocalhost%26relation%3Dparent%26frame%3Df2c40b1914&response_type=tokendk=Cjoeyfromrequest_type=tokendk= Cjoey网址http://www.facebook.com/plugins/like.php?action=like&api_key=248753205242460&channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D9%23cb%3Df458cef1c% 26origin%3Dhttp%253A%252F%252Flocalhost%252Ff2ad19772%26domain%3Dlocalhost%26relation%3Dparent.parent&colorscheme=light&extended_social_context=false&font=segoe%20ui&href=http%3A%2F%2Fecommercedeveloper.com&layout=standard&locale=en_US&node_type=link&sdk=joey&sdk= 400# . 域、协议和端口必须匹配。不安全的 JavaScript 尝试使用 URL https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=9#channel=f2ad19772&origin=http%3A%2F%2Flocalhost&channel_path=%2FDummy%2FFBplugin%2Ffb访问框架.http://www.facebook.com/plugins/like.php?action=like&api_key=248753205242460&channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D9%23cb%3Df458cef1c% 26origin%3Dhttp%253A%252F%252Flocalhost%252Ff2ad19772%26domain%3Dlocalhost%26relation%3Dparent.parent&colorscheme=light&extended_social_context=false&font=segoe%20ui&href=http%3A%2F%2Fecommercedeveloper.com&layout=standard&locale=en_US&node_type=link&sdk=joey&sdk= 400# . 域、协议和端口必须匹配。

我不知道为什么会出现该错误,可能是因为触发了检查登录的代码..

这是我的html:

<!DOCTYPE html>

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

       <script type="text/javascript">
 $(document).ready(function(){          

          FB.init({
            appId      : '248753205242460', // App ID
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
            });   



window.fbAsyncInit = function() {
            console.log('Sdk is loaded');


FB.getLoginStatus(function(response) {
                console.log('GEtting logged in status');

  if (response.status === 'connected') {
    // the user is logged in and has authenticated your
    // app, and response.authResponse supplies
    // the user's ID, a valid access token, a signed
    // request, and the time the access token 
    // and signed request each expire
    var uid = response.authResponse.userID;
    console.log('User is connected');
    var accessToken = response.authResponse.accessToken;
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app
     console.log('User not authorized');
  } else {
    // the user isn't logged in to Facebook.
     console.log('User inst logged in');
  }
 });
};



 FB.Event.subscribe('edge.create',
    function(response) {
        console.log('You liked the URL: ' + response.status);
    });

});





       </script>        
    </body>
</html>
4

2 回答 2

1

我正在使用的另一个事件是“getLoginStatus”,它会告诉我用户是否登录到 facebook。

这本身不是一个“事件”——它只是一个异步方法,它可以让你获得登录状态。

console.log('FB.getLoginStatus: '+FB.getLoginStatus);

此时,您甚至都没有调用该方法——您只是在说明它的名称。(我知道,你之前调用过它——但是这个调试输出没有多大意义。)

我想触发 edge.create

你究竟是如何实现你的喜欢按钮的?如果您使用的是 iframe 版本的按钮,则不会触发此事件。

[来自评论] 我想我需要有自己的应用程序 ID ......这可能是原因吗?这是我的 Facebook 名称,而不是数字

你当然知道。您的用户名无论如何都不是应用程序 ID。

于 2012-07-18T11:23:19.330 回答
1

错误消息通常暗示您的 http 协议有问题Unsafe JavaScript attempt to access frame with URLDomains, protocols and ports must match您是否应该对这些调用使用 HTTPS 而不是普通的 HTTP?

当我看到这些错误时,我通常会测试我是否在某处丢失了 https ......

另请查看您的应用是否在 facebook 的开发人员管理面板中设置了所有安全 URL!

于 2012-07-18T12:17:10.967 回答