Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Facebook comments count with HTML5?

Tags:

html

facebook

I know two ways to retrieve the number of comments on Facebook:

<fb:comments-count href=http://example.com/></fb:comments-count> awesome comments 

and...

<iframe src="http://www.facebook.com/plugins/comments.php?href=example.com&permalink=1" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:130px; height:16px;" allowTransparency="true"></iframe> 

But none is a semantics for HTML5 solution, is there any alternative?

like image 470
Caio Tarifa Avatar asked Oct 04 '11 02:10

Caio Tarifa


1 Answers

You can also get HTML5 valid FB comment count this way:

<div class="fb-comments-count" data-href="/post URL">0</div>

FB automatically replaces the "0" with the correct number. If you put something there like "awesome comments", it will be replaced with the number of comments i.e. "13", etc.

In order to get the number and use your own text, do something like this:

<a href="/post URL"><div class="fb-comments-count" data-href="/post URL">0</div> awesome comments</a>

Notice you must wrap your class in div's or else the comment counter will not work.

like image 154
Charlie Nibbana Avatar answered Oct 20 '22 01:10

Charlie Nibbana