Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get random Twitter follower from your exported followers.js
<?
// str_replace removes the JS part and makes it into a normal JSON file
$followers=json_decode(str_replace('window.YTD.follower.part0 = ','',file_get_contents(__DIR__.'/followers.js')),true);
echo "\n\n";
echo number_format(count($followers)).' followers';
echo "\n\n";
echo "\n\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
function mt_array_rand(Array $array, $num = 1) {
$count = count($array);
if ($num > $count) {
return null;
}
$keys = array_keys($array);
$res = [];
for ($i = 0; $i < $num;) {
$rand = mt_rand(0, $count - 1);
if (isset($res[$keys[$rand]])) {
continue;
}
$res[$keys[$rand]] = $i;
$i++;
}
$res = array_flip($res);
sort($res);
return (count($res) === 1) ? reset($res) : $res;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.