I have run my personal website https://www.rozenek.com . You are just looking at the page š My website has about 700Ā posts and subpages (on May 2014). All pages and posts have individual like buttons.
I started to wonder, how can I know which pages have been liked and how many times?
I have already found that I cannot know names of persons who clicked like and they are not my friends. I just wanted to know which pages were clicked with the like button and how many times.
So I decided to ask for support on the facebook forumĀ https://www.facebook.com/help/community/question/?id=10203466634168271&added.
Facebook support system is unbelievably useless – after a week my question was seen by… 3 people including me, hahahaha.
Well, because I know a bit about PHP and MySQL databases I decided to do a very simple script which shows me what articles are liked by people.
The script below has a few cons. Firstly, it shows all articles, does not matter they are liked or not. Secondly it works only with WordPress. However, if you know how your website works, you can very easily modify this script.
The script code:
<?
#################### MySQL connection ###############################
$dbhost=”localhost”;
$dbuser=”****************”;
$dbpass=”****************”;
$dbname=”***************”;
mysql_connect($dbhost, $dbuser, $dbpass) or die (“Can not connect to the datebase”);
mysql_select_db($dbname) or die (“Can not choose database names: $dbname – ” . mysql_error());
echo ”
<html>
<head>
<title>FBĀ Likes</title>
</head>
<body>
<table style=\”width: 80%; float: center; margin: auto; border-collapse: collapse (separate); border: 1px solid green;\”>”;
$result=mysql_query(“SELECT post_nameĀ FROM wp_postsĀ WHEREĀ post_type=’post'”);
while ($get = mysql_fetch_array($result))
{
echo ” <tr>
<td style=\”border: 1px solid black; width: 50%\”>
<iframe src=\”//www.facebook.com/plugins/like.php?href=https://www.rozenek.com/” . $get[‘post_name’] . “/&width&layout=standard&action=like&show_faces=true&share=true&height=80&appId=646582575415297\” scrolling=\”no\” frameborder=\”0\” style=\”border:none; overflow:hidden; height:80px;\” allowTransparency=\”true\”></iframe>
</td>
<td style=\”border: 1px solid black; width: 50%\”>Title: ” . $get[‘post_name’] . “</td>
</tr>”;
}
echo “</table></body></html>”;
?>