How to save Facebook comments count to Mysql database?
Posted by February 19, 2012 2 Comments

I use the Facebook API on my website to allow users to comment on different pages.

This is how to get the comments count for a specific page:

<fb:comments-count href='LINK_TO_PAGE'></fb:comments-count>
I want to store this value into a MySQL database, allowing users to sort by most Facebook comments. It would be most efficient if i could store this value, only when a person makes a new comment. How can I do this? (Haven't found anything useful in FB docs yet…)

hoanhuynh Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam interdum commodo pulvinar. Nunc consequat erat nec quam dapibus posuere non ac massa.

(*) If you'd like to custom a particular module or request Technical support relate to CMS (WordPress,Umbraco,etc) implementation/customization, Social Media API (Facebook, YouTube, Google, etc) implementation, domain, web hosting stuff, ...
read more
  • http://4rapiddev.com/ Hoan Huynh
    Select as Best Answer

    Hi there, you could use something like this: 

    http://api.facebook.com/restserver.php?method=links.getStats&urls=http://4rapiddev.com/facebook-graph-api/get-or-find-facebook-profile-id-number/

    and replace my url with yours.

    More information here: http://developers.facebook.com/docs/reference/rest/links.getStats/

    Hope it answers your question.

    Cheers,
    H2.

  • http://4rapiddev.com/ Hoan Huynh
    Select as Best Answer

    Sorry, me again :)

    You can try with PHP function: file_get_contents:

    file_get_contents(‘http://api.facebook.com/restserver.php?method=links.getStats&urls=_your_url_’); 

    And shouldn’t update the total comments in the real time. I may slow down your application.  Let’s use a schedule instead.

    H2.