-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathself_non_followers_unfollower.php
74 lines (69 loc) · 2.51 KB
/
self_non_followers_unfollower.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
require __DIR__."/vendor/autoload.php";
require __DIR__."/config.php";
$instagram = new \InstagramAPI\Instagram(false, false);
$signature = \InstagramAPI\Signatures::generateUUID();
try
{
echo("[?] Try for login as {$account['username']}...\n");
$instagram->login($account['username'], $account['password']);
echo("[!] Login successfully!\n");
sleep(2);
echo("[!] Getting self following...\n");
$next_max_id = null;
$following_count = 0;
$following_pool = [];
do
{
$following_users = $instagram->people->getSelfFollowing($signature, null, $next_max_id);
foreach($following_users->getUsers() as $following_user)
{
array_push($following_pool, $following_user->getPk());
}
$next_max_id = $following_users->getNextMaxId();
}
while($next_max_id !== null);
echo("[!] Getting self followers...\n");
$next_max_id = null;
$followers_count = 0;
$followers_pool = [];
do
{
$followers_users = $instagram->people->getSelfFollowers($signature, null, $next_max_id);
foreach($followers_users->getUsers() as $followers_user)
{
array_push($followers_pool, $followers_user->getPk());
}
$next_max_id = $followers_users->getNextMaxId();
}
while($next_max_id !== null);
echo("[!] Analyzing self following and self followers list...\n");
$users = array_values(array_diff($following_pool, $followers_pool));
echo("[!] ".count($users)." user is not follow back you...\n");
$unfollowed = 0;
foreach($users as $id => $pk)
{
$unfollow = $instagram->people->unfollow($pk);
if($unfollow->getStatus() == "ok")
{
echo "[+] ".date("d-m-Y H:i:s")." on ".$instagram->people->getInfoById($pk)->getUser()->getUsername()." user was unfollowed.\n";
sleep($self_non_followers_unfollower['interval']);
$unfollowed++;
unset($users[$id]);
}
else
{
echo "[!] ".date("d-m-Y H:i:s")." on have a error, please wait for next job in {$self_non_followers_unfollower['have_err']} seconds.\n";
sleep($self_non_followers_unfollower['have_err']);
}
if($unfollowed === $self_non_followers_unfollower['max_unfollow'])
{
echo "[!] ".date("d-m-Y H:i:s")." on unfollowed {$self_non_followers_unfollower['max_unfollow']} users, Job successfully completed.\n";
die;
}
}
}
catch(Exception $e)
{
echo("[!] ".$e->getMessage()."\n");
}