Loop“Addfriend”计数问题
问题描述:
我有以下代码,它完美地工作。但是我遇到了一个小问题:“$ username_index”计数。Loop“Addfriend”计数问题
我的代码的主要思想是以下:
具有accounts.txt [92行]用户名:通格式。 拥有usernames.txt [99999行]用户名格式。
它将登录到account1,然后它将添加95个用户名,然后下一个account2,然后添加下95个用户名。
但有些帐户给出回复“太多添加朋友”。在这种情况下,我将跳过该帐户并转到下一个。
但是下面的代码将冲突到下一个95 !,所以它从用户名跳过95!
我希望它contiue添加从跳过的帐户的左侧用户名。
我希望它尽快登录到下一个帐户,并随时添加下一行USERNAMES!无需跳转到下一个95用户名添加!
Example how i want it:
login account1
add username1
add username2
ERROR APPEARS!
login account2
add username3
add username4
add username5
add username6
error appears!
login account3
add username7
add username8
etc..
目前代码:
$username_index = 0;
while(true) { // This is our while.. yes but this not for login()!
try {
$names = readFromFile("usernames.txt", 95, $username_index);
if(count($names) <= 0)
break;
sleep(1);
$fuckc = 0;
foreach($names as $name){
$ans = $API->addFriend($name);
$var_response = $ans->getMessage();
if (strpos($var_response, 'too many friends!') !== false) {
printf("[!] Too many friends!, Skipping account now.\n");
break;
}
if (strpos($var_response, 'Sorry') === false) {
$fuckc++;
printf("[+]" . "[" . date("h:i:s") . "]" . "[" . $fuckc . "] " . "response: " . $var_response . "\n");
//printf("[" . $fuckc . "] " . "response: " . $var_response . "\n");
}
//sleep(SLEEP_TIME);
}
$username_index += 95;
$API->logout();
//rotate_proxy();
$API = null;
//sleep(waiting);
//$results = $findFriends->getResults();
if (!isset($results) || count($results) == 0) {
if(!login()) die("Could not find a valid account.\n");
}
} catch(Exception $e){
echo $e->getMessage() . "\n";
if(!login()) die("Could not find a valid account.\n");
}
}
答
再次编辑:计数器$username_index
只有increasse时$var_response
不是 “太多啦!” :
$username_index = 0;
while(true) { // This is our while.. yes but this not for login()!
try {
$names = readFromFile("usernames.txt", 95, $username_index);
if(count($names) <= 0)
break;
sleep(1);
$fuckc = 0;
foreach($names as $name){
$ans = $API->addFriend($name);
$var_response = $ans->getMessage();
if (strpos($var_response, 'too many friends!') !== false) {
printf("[!] Too many friends!, Skipping account now.\n");
break;
}
else $username_index++; //◄■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
if (strpos($var_response, 'Sorry') === false) {
$fuckc++;
printf("[+]" . "[" . date("h:i:s") . "]" . "[" . $fuckc . "] " .
"response: " . $var_response . "\n");
//printf("[" . $fuckc . "] " . "response: " . $var_response . "\n");
}
//sleep(SLEEP_TIME);
}
// $username_index += 95; //◄■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
$API->logout();
//rotate_proxy();
$API = null;
//sleep(waiting);
//$results = $findFriends->getResults();
if (!isset($results) || count($results) == 0) {
if(!login()) die("Could not find a valid account.\n");
}
} catch(Exception $e){
echo $e->getMessage() . "\n";
if(!login()) die("Could not find a valid account.\n");
}
}
感谢您的关注。如果出现错误,代码将移至下一个帐户,或者如果完成95次添加。而已。 –
@mzabox,现在有什么问题?我在这里解决它。 –
现在你的代码工作得很好,但它突然停止,它不会循环无限。 –