简体   繁体   English

Facebook对图片的评论不起作用

[英]Facebook comments for pictures do not work

I have a picture gallery and I use fancybox to display pictures, and navigate between pictures. 我有一个图片库,并且使用fancybox来显示图片并在图片之间导航。 Beneath the pictures I integrated the facebook comments plugin to be able to add specific comments for every picture in part. 在图片下方,我集成了facebook评论插件,以便能够为部分图片添加特定评论。 My problem is that the comments added by people for a specific picture do not appear. 我的问题是,人们针对特定图片添加的评论不会出现。 However if I add a comment it does show up, but these are only my comments and they appear only if I'm logged in to facebook. 但是,如果我添加评论,它的确会显示出来,但这只是我的评论,只有在我登录到Facebook后才会显示。 Does anybody have some idea what can I do wrong? 有人知道我该怎么办吗?

The url for the facncybox gallery is: http://www.bass.hr/photogallery.php?album=17 For the facebook comments integration I use the code generated from https://developers.facebook.com/docs/reference/plugins/comments/ . facncybox画廊的URL是: http : //www.bass.hr/photogallery.php? album =17对于Facebook注释集成,我使用从https://developers.facebook.com/docs/reference/生成的代码插件/评论/

Here is my code: 这是我的代码:

<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&appId=196368707123454";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

<div id="fancybox_container" style="display:none;">
    <?php
    foreach ($Imgs as $key => $i) {
    ?>
            <div id="inline_<?php echo $key;?>" style="width:500px;">
                <img id="fancyboxContentImage" src="<?php echo $target.$i['filename']; ?>" />
                <div style="margin-top:20px;">
                    <fb:comments href="http://www.bass.hr/<?php echo $target.$i['filename'];?>" num_posts="2" width="450"></fb:comments>
                </div>
            </div>
            <a class="grouped_elements" href="#inline_<?php echo $key;?>" rel="group" ></a>
    <?php
    }
    ?>
</div>

<script type="text/javascript">

$(window).load(function(){
    $("a.grouped_elements").fancybox({
        openEffect   : 'fade',
        closeEffect  : 'fade',
        nextEffect   : 'fade',
        prevEffect   : 'fade',
        mouseWheel   : 'true',
        width        :  520,
        height       :  400,
        autoSize     : 'true',
        fitToView    : 'true',
        type         : 'inline',
        scrolling    : 'yes',
        padding      : 10,
        afterShow    :function() {
            var referenceHeight = $('div.fancybox-inner div img').height()+15;
            $('.fancybox-prev, .fancybox-next').css('height', referenceHeight+'px');
        }
    });
    $("#fancybox_container a.grouped_elements:first").click();
});
</script>

Update1: 更新1:

I also tried to load the facebook JavaScript SDK asynchronously like described in facebook developers JavaScript SDK reference, but just the same result. 我还尝试像Facebook开发人员JavaScript SDK参考中所述异步加载Facebook JavaScript SDK,但结果相同。

Update2: 更新2:

I also checked the url of my images by inspecting with firebug. 我还通过检查萤火虫来检查图像的URL。 If I copy that url and give it as a parameter to the graph api, then the comments are there in the array returned (see comments below for the url that I tried via graph api) 如果我复制该URL并将其作为参数提供给图形API,则注释将存在于返回的数组中(有关通过图形API尝试使用的URL,请参见下面的注释)

Update3: 更新3:

I created a sepparate test page containing only the image and the facebook comments plugin under it. 我创建了一个单独的测试页,其中仅包含图片和其下方的Facebook评论插件。 After that I passed the url to the debugger, so it flushes the cache, but no result. 之后,我将URL传递给调试器,因此它刷新了缓存,但没有结果。 Here is the url with only the image+plugin: bass.hr/photodisplay.php?photo=pic_1293187827.jpg 这是仅包含图片和插件的网址:bass.hr/photodisplay.php?photo=pic_1293187827.jpg

Any ideas, not necessarily solutions would be much apreciated also. 任何想法(不一定是解决方案)也将受到重视。

Thanks in advance. 提前致谢。

XFBML tags are only parsed on Facebook JS-SDK initialization by default (once DOM is ready). 默认情况下,仅在Facebook JS-SDK初始化上解析XFBML标签(一旦DOM准备就绪)。 And hidden content is probably skipped. 隐藏的内容可能会被跳过。 You need to call FB.XFBML.parse once you want to render XFBML tags to page 要将XFBML标记呈现到页面时,需要调用FB.XFBML.parse

You can do it for every tag on page or in specified node only by passing it as argument to FB.XFBML.parse method 您只能通过将其作为参数传递给FB.XFBML.parse方法来对页面上或指定节点中的每个标签执行此操作

Update: Looks like it not really directly related to XFBML rendering but to some character in one of filenames passed to onload function which prevents FB.XFBML for loading on page (and this is why any XFMBL tags not rendered at all), wired it happens only on Chrome/Chromium but not of Safari (tested both). 更新:看起来它与XFBML呈现并没有真正的直接关系,但与传递给onload函数的文件名之一中的某个字符有关,这阻止了FB.XFBML在页面上加载(这就是为什么XFMBL标记根本未呈现)的原因,只能在Chrome / Chromium上使用,而不能在Safari上使用(两者都进行了测试)。

<body class="background_main" style="background-image: url(../Images/blackjack3.jpg);" onload="MM_preloadImages('Images/home2.png','Images/o
nama2.png','Images/photogallery2.png','Images/forum2.png','Images/news2.png','Images/kontakt2.png')">

This is the error I'm see in Chromium (for some reason the real error can be seen only sometimes in correct place and most times attributed to Facebook's all.js) 这是我在Chromium中看到的错误(由于某些原因,真正的错误只能在正确的地方看到,大多数时候归因于Facebook的all.js)

Uncaught SyntaxError: Unexpected token ILLEGAL (photogallery.php:66) 未捕获的SyntaxError:意外的令牌非法(photogallery.php:66)

Update 2: 更新2:

If comments other users posted isn't displayed (or displayed for comment posted only) it may be some reasons: 如果未显示其他用户发布的评论(或仅针对发布的评论显示),可能是由于以下原因:

  • Moderation is enabled for comments 已启用审核功能
  • Comments posted as testing users 以测试用户身份发布的评论
  • For some users marked as spammers (controlled by Facebook) comments isn't displayed 对于某些标记为垃圾邮件发送者(由Facebook控制)的用户,不会显示评论
  • Facebook bug (which is possible but probably isn't a case) Facebook错误(可能,但并非如此)

Update 3: 更新3:

This is probably bug, it may be tracked on http://developers.facebook.com/bugs/117814361658299 这可能是错误,可能会在http://developers.facebook.com/bugs/117814361658299上进行跟踪

Figured out.. it seems that facebook does not let new created users to post comments immediately. 想通了..看来Facebook不允许新创建的用户立即发表评论。 If anyone runs into this again check this also. 如果有人再次遇到这个问题,也请检查一下。

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

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