this problem has been killing me and I could not find a solution.
I implement a scoring system based on links in PHP.
A person "A" can post a link on social networks like Twitter and when another person "B" open this link, the individual A wins 10 points.
The problem is that when the link is posted on twitter for example. It opens so many times giving too many points to the other person.
I have tried to identify the User agent in PHP to determine when a human opens the link, but some twitter hits look like this:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
This could clearly be a human, but it is not, Because that user agent opened twice the link in the same second with 2 different IP. 52.19.163.13 and 52.16.66.216. If I'm not mistaken are Amazon servers.
Even I excluded all the robots in robots.txt but is not working. This is the way I try to identify a human.
$app->get('/link/:code', function($codigo){
if(is_human() and !is_bot())
{
$res = $db->giveCoins($codigo);
if ($res !== 0) {
echo "Redirect to another page"; //cannot be a human interaction on this page
}else
{
echo "Robot";
}
}
});
And these are the functions I use to analyze the User Agent:
function is_bot(){
$botlist = array("Gigabot", "Googlebot",
"FlipboardProxy", "Purebot",
"facebookexternalhit","applebot",
"Google-HTTP-Java-Client",
"Chrome/33.0.0.0");
foreach($botlist as $bot){
if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
return true; // Is a bot
}
return false; // Not a bot
}
function is_human(){
$humanlist = array("Android","Safari",
"Chrome","OPR","Opera",
"Chromium","Firefox");
foreach($humanlist as $bot){
if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
return true; // Probably a human
}
return false; // Probably not a human
}
I do not know if there is a smarter way to determine if is a human who opens the link. Thanks for the attention