Last week I searched a lot and tested different plugins to add facebook comments and like buttons. The one that I most liked was Plugin Total Facebook, it is easy and have good position settings.
Right now, the facebook does not notificate you about new comments or like that your post receives, so I decided to code this using Javascript SDK. I used the event interface to know when somebody Like or Comment on your publication.
A lot of my tests returned the FB object was inexistent (Uncaught ReferenceError: FB is not defined), the FB.init was already called (FB.init has already been called – this could indicate a problem) and other erros. So i modified the function fbsdk_includeWFC() to do the init async and add a function to be called when a “edge.create” (Like) event or “comment.create” (Comment) event are done.
[code lang=”php”]
function fbsdk_includeWFC(){
$wfcglb = get_option(‘wfc_global’);
echo ”
window.fbAsyncInit = function() { FB.init({ appId : '" . $wfcglb['appid'] . "', // App ID //channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML });
FB.Event.subscribe('comment.create', function (response) { jQuery.ajax({ url: 'test.html', //success: function (data) { alert(response.href); }, //error: function (data) { alert(response.href); } }); }); };
FB.Event.subscribe('edge.create', function (response) { jQuery.ajax({ url: 'test2.html', //success: function (data) { alert(response); }, //error: function (data) { alert(response); } }); }); };
(function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = '//connect.facebook.net/en_US/all.js'; ref.parentNode.insertBefore(js, ref); }(document));“;
echo ““;
}
[/code]
Now you can modified the “url” from ajax calls to call a php url and pass parameters, and with this parameters send you an e-mail for example.
Hope this is useful for you
Matheus
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.