【问题标题】:Posting on Facebook ... works fine but throws error in console WHY?在 Facebook 上发帖 ... 工作正常,但在控制台中抛出错误 为什么?
【发布时间】:2011-08-04 21:06:50
【问题描述】:

我设置了一个 FB.ui 提要,用于触发与 Facebook 的对话,就像在 here 中描述的那样。

到目前为止一切正常。该对话框被发布在 fb 用户个人资料上,但是当 fb 站点打开用户操作以发布对话框时,它会在 js 控制台中引发数百次错误,直到用户跳过或发布:

错误(130次): 不安全的 JavaScript 尝试使用 URL ... 访问框架。域、协议和端口必须匹配。

带有 i init fbjs sdk 的 appId 已在使用的域中注册:

sub.mydomain.com

交出来的json是这样的:

代码:

window.fbAsyncInit = function() {
    FB.init({appId: '209836882377466', status: true, cookie: true,
        xfbml: true
    });             
};          
(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    if (!$('#fb-root script').length>0){
        document.getElementById('fb-root').appendChild(e);
    }

}());

这里是提要:

 var jSON = {
                method: 'feed',
                name: $('#fbName input').val(),
                link: basicLnkStruct + phpSessionID,
                picture: homeURL + imgPath,
                caption: ' ',
                description: $('.fbDescript textarea').val(),
                message: ''
            };
    FB.ui(
        jSON
        ,
        function(response) {
            if (response && response.post_id) {
                 //alert('Post was published.');
            } else {
                //alert('Post was not published.');
            }
        }

    );

为什么会抛出这个错误?

【问题讨论】:

  • 莫非跟子域有关?

标签: javascript facebook facebook-javascript-sdk


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2018-07-26
  • 2012-04-07
  • 1970-01-01
  • 2019-08-30
  • 2020-03-06
  • 1970-01-01
  • 1970-01-01
  • 2019-04-11
相关资源
最近更新 更多