I added Facebook Comments to a WordPress blog. The comment box header (says x comments with a drop down arrow and an "add a comment" link) is not showing up. See the default comment box at https://developers.facebook.com/docs/plugins/comments/.
I inserted the following after the opening body tag:
<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=1432741046964019";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
And the following function to load comments if comments are open:
function sitc_load_facebook_comments() {
if ( comments_open() ) {
echo '<div class="fb-comments" data-href="';
echo get_permalink();
echo '" data-numposts="5" data-colorscheme="light"></div>';
}
}
Not sure if there has to be over five comments in order for the header to show up?
Use this tag. Found on the FB comment doc :)
<fb:comments-count href=yourURL></fb:comments-count>
Related
Currently I am using a bit of code from Facebook to generate comment boxes on my site. I dynamically generate a different comment box for each article on the site -- and it works! -- but the problem is that I have SO many different comment boxes pointing to so many different URLs and I did not generate the comment boxes through any central Facebook app, so I am unsure how to check the users/comments that I receive in those boxes!
Below is the code that I use to generate the comment box on each page, with the $url variable is always equal to the URL that the comment box is being displayed on:
<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=";
fjs.parentNode.insertBefore(js, fjs);
(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php echo $url ?>" data-num-posts="12" data-width="100%"></div>
Is there any way to check for comments if this is how I generate my comment boxes?
I am using below code to implement facebook comment box on my site pages :
<div class="fb-comments" data-href="http://example.com/test/public/story/read-searched-story?story=rRDMpYpeHA22aFm4OFahuV50iFqswqjzFzl7BJPbnyo=" data-numposts="5" data-colorscheme="light"></div>
<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/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
When i am posting comment it asks to publish on facebook and when i click on post nothing happens either on my wall or activity log. any help will be appreciated..!!
After searching a lot found that facebook crawler needs some ogtags to crawl all pages mentioned on https://developers.facebook.com/docs/reference/opengraph/object-type/website/ and you can check your URL on https://developers.facebook.com/tools/debug/.
I have created an facebook comment box,here's the question,if user's adding comment from random articles on the website,the comment will not shown as they comment from articles,but for whole site.how could I make this facebook comment for each articles?thanks in advance
In Javascript, the script remains the same for each articles. It looks like:
<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_GB/all.js#xfbml=1&appId=YOUR_APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
As for the HTML, you'll have to update the data-href attribute depending on the page (article) where you are.
<div class="fb-comments" data-href="http://example.com/CURRENT_ARTICLE" data-width="470" data-num-posts="2"></div>
I want use the comments box on my site to comment posts. I paste the code generated in my page
<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/it_IT/all.js#xfbml=1&appId=IDAPP";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="https://facebook.3rdplace.com/zend/ibs_post.php?id=<?=$id_post?>" data-num-posts="2" data-width="470"></div>
If I post a comment, it appears, but it's not saved on Graph.
Where's the problem??
Ensure your data-href URL is accessable externally. Apart from that you could try and debug it using the comment.create event.
Like this:
FB.Event.subscribe('comment.create', function(comment) {
console.log(comment); // looking for comment.commentID - https://graph.facebook.com/<comment_id>
});
I am using facebook comments and providing the url of the page to distinguish. here is the code I am using
<?php $commenturl="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>
<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>
<fb:comments href="<?php echo $commenturl?>" num_posts="8" width="670"></fb:comments>
My url is www.domain.com/foldername/index.php?etc.
so it shows up the comment feed ok, but once someone posts a comment the url on his wall omits the foldername and directly goes to mangoestv.com/index.php?etc.
what am I supposed to do?
I had the same problem was solution was to use htaccess to rewrite url , because it seems that facebook considers domain.com/index.php?var=abc and domain.com/index.php?var=xyz the same
so you should have url like that domain.com/abc and domain.com/xyz
Edit :
info about rewriting url's
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
http://corz.org/serv/tricks/htaccess2.php