Intro
Have you ever wanted to post how many facebook likes your page has on your website? If so, now is your chance to learn so read carefully. In this tutorial you will make a document called "likes.php".
Using Graph API
Graph API is a simple API system that gives you information about a page or a document using JSON. You can access it by this link. http://www.graph.facebook.com/YOUR_USERNAME_HERE
For example you can view Facebook.com's info here: Facebook
The Code
Insert this code into "likes.php" the page you made earlier in this tutorial.
Change "facebook" with your page's id or username.Code:<html> <head> <title>Likes Counter</title> </head> <body> <blockquote> <?php //Get content of the URL $input = file_get_contents("http://graph.facebook.com/facebook"); //Decode the JSON content into class $output = json_decode($input); //Output number of likes echo $output->likes; ?> </blockquote> </body> </html>



LinkBack URL
About LinkBacks





Reply With Quote
It shows a simple way of using Facebook's API to display likes. Some website owners pay developers to do these things despite it being quite easy.


Bookmarks