<?php
header('Content-Type: text/html; charset=utf-8');
header('Content-type: text/plain');
/* runegear.net */
/* twitter name to follow */
$client = "client.txt";
/*
* twitter accounts seperated like so:
* user@user.com:password
* user2@user.com:pass2
*/
$twitters = "logins.txt";
if (!file_get_contents($client) || !file_get_contents($twitters)) {
die("# File $client or $twitters Missin!");
}
$client = explode("\n", file_get_contents($client));
$twitters = explode("\n", file_get_contents($twitters));
$fp = @fopen('output_' . date('d_m_Y__H_i') . '.txt', 'w');
if (!$fp)
echo "\n#Unable to create log\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "&follow=true");
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
echo "# Start of script " . date('d/m/Y H:i:s') . " \n\n";
if ($fp)
fwrite($fp, "# Start of script " . date('d/m/Y H:i:s') . "\n\n");
foreach ($twitters as $twitter) {
flush();
list($login, $lis) = explode(":", $twitter);
if (preg_match('/^\@/', $login))
$login = preg_replace('/^\@/', '', $login);
$lis = str_replace(Array(
"\r",
"\n"
), "", $lis);
if (empty($login) || empty($lis))
continue;
$auth = (string) "$login:$lis";
foreach ($client as $a) {
flush();
$a = str_replace(Array(
"\r",
"\n"
), "", trim($a));
if (!is_resource($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "&follow=true");
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
}
curl_setopt($ch, CURLOPT_URL, "http://api.twitter.com/1/friendships/create/$a.xml");
curl_setopt($ch, CURLOPT_USERPWD, trim($auth));
$res = @curl_exec($ch);
if (preg_match('/error( code="\d+")?>(.+?)<\/error>/i', $res, $error)) {
curl_close($ch);
echo "# O login $login not able to follow $a (" . $error[2] . ") !\n";
if ($fp) {
fwrite($fp, "# O login $login not able to follow $a (" . $error[2] . ") !\n");
}
} else {
echo "# O $login followed $a !\n";
if ($fp) {
fwrite($fp, "# O $login followed $a !\n");
}
}
flush();
ob_flush();
}
flush();
ob_flush();
}
echo "\n# End of the script " . date('d/m/Y H:i:s') . "\n";
if ($fp) {
fwrite($fp, "# End of the script " . date('d/m/Y H:i:s') . "\n");
fclose($fp);
}
?>