Last active
December 16, 2015 04:29
-
-
Save Korko/5377865 to your computer and use it in GitHub Desktop.
Simple tool to select a random facebook user who likes a story
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_GET['stories'])) { | |
die('USAGE : randomLikes.php?stories=<story id,story id...>'); | |
} | |
$stories = explode(',', $_GET['stories']); | |
$alldata = array(); | |
foreach($stories as $story) { | |
$url = 'https://graph.facebook.com/'.intval($story).'/likes?limit=0'; | |
$alldata += json_decode(file_get_contents($url), true))['data']; | |
} | |
$rand = $alldata[array_rand($alldata)]; | |
$calldata = count($alldata); | |
$listalldata = ''; | |
foreach($alldata as $data) { | |
$listalldata .= '<li><a href="http://www.facebook.com/'.$data['id'].'">'.$data['name'].'</a></li>'; | |
} | |
echo <<<EOT | |
<html> | |
<head> | |
<title>Random Likes</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
</head> | |
<body> | |
<p>The winner is : <a href="http://www.facebook.com/{$rand['id']}">{$rand['name']}</a></p> | |
<p> | |
There was {$calldata} participants for story <a href="http://www.facebook.com/{$_GET['story']}">{$_GET['story']}</a> : | |
<ul>{$listalldata}</ul> | |
</p> | |
</body> | |
</html> | |
EOT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment