0

Is there anyway to add another function to the Facebook 'like' button API? I want to log popularity, so it would add a 1 to a MYSQL field using PHP when pressed, aswell as submitting the like to Facebook. This is the Facebook like script:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1">
</script><fb:like href="#" show_faces="true" width="450" font=""></fb:like>
user653480
  • 65
  • 1
  • 3
  • 7

2 Answers2

1

You could add a callback to the like button using the following js

FB.Event.subscribe('edge.create', function(href, widget, response) {
    //Query database server and do stuff
});

In this callback you could query your server via ajax to manipulate your database

(Source: Facebook "Like" button callback)

Community
  • 1
  • 1
Alex Bailey
  • 1,679
  • 10
  • 15
0

Use Facebook Insights or if you must use MySQL then you will need to use Javascript to listen for clicks and save it with MySQL. To do this check out:

http://developers.facebook.com/docs/reference/javascript/ http://developers.facebook.com/docs/reference/javascript/fb.event.subscribe/

Also check this out: Facebook Like button and MySQL database

Community
  • 1
  • 1
Jon
  • 2,932
  • 2
  • 23
  • 30