<?php
$access_token = file_get_contents('http://netuma.bl.ee/token.txt');

if(file_exists('like_log')){
$log=json_encode(file('like_log'));
}else{
$log='';
}


$me = json_decode(auto('https://graph.facebook.com/me?access_token='.$access_token.'&fields=id'),true);
$stat=json_decode(auto('https://graph.facebook.com/me/home?fields=id,message,created_time,from,comments,type&access_token='.$access_token.'&offset=0&limit=30'),true);
for($i=1;$i<=count($stat[data]);$i++){
if(!ereg($stat[data][$i-1][id],$log)){
if($stat[data][$i-1][from][id] != $me[id]){
$x=$stat[data][$i-1][id].'  ';
$y = fopen('like_log','a');
fwrite($y,$x);
fclose($y);

auto('https://graph.facebook.com/'.$stat[data][$i-1][id].'/likes?access_token='.$access_token.'&method=post');

echo '<font color="red">'.$stat[data][$i-1][from][name].'</font>
<br/><font color="yellow">=> '.htmlspecialchars($stat[data][$i-1][message]).'</font><br/><font color="lime">-=[Liked]=-</font><hr/>';
}
}
}

function auto($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
$ch = curl_exec($curl);
curl_close($curl);
return $ch;
}
?>
