-
Notifications
You must be signed in to change notification settings - Fork 0
/
getlistoffriendsfollowers.php
102 lines (59 loc) · 2.58 KB
/
getlistoffriendsfollowers.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require_once('twitter-api-php/TwitterAPIExchange.php');
$screen_name = "UofMaryland";
$settings = array(
'oauth_access_token' => "811975859070443523-s3idYBSPXlzDvhqk5JqRJWnOHeQzeqA",
'oauth_access_token_secret' => "TmBiYjr26JBP2IZvtuDNEO15B0vZaDJSPCN9JFrr2hXg3",
'consumer_key' => "lKa06EW2OGOOXAsTffccUEYU1",
'consumer_secret' => "iLFJnZYfuMCH38Juum3orEAfX2QU4pMW4y5LAXlQgmfsd4uGFr"
);
$restartcursor = 1565506688821987905;
$url = 'https://api.twitter.com/1.1/followers/list.json';
$getfield = '?screen_name='.$screen_name.'&skip_status=true&include_user_entities=true&count=5000';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield."&cursor=".$restartcursor)
->buildOauth($url, $requestMethod)
->performRequest();
$mydata = json_decode($response,true);
$firstpage = "First_Page";
$previouscursor = $mydata["previous_cursor"];
$cursor = $mydata["next_cursor"];
$status = $twitter->getHttpStatusCode();
echo "You wanted" . " " . $screen_name . " ". "Followers from Twitter : " . "\n" ;
echo $firstpage ." ". "has printed". "\n";
file_put_contents( "uomaryland/".$firstpage.".json", serialize($mydata), FILE_APPEND) ;
do {
$cursor = $mydata["next_cursor"];
$response = $twitter->setGetfield($getfield."&cursor=".$cursor)
->buildOauth($url, $requestMethod)
->performRequest();
$mydata = json_decode($response,true);
echo $cursor ." ". "has printed". " ". "with a response code of: ".$status."\n";
file_put_contents( "uomaryland/".$cursor.".json", serialize($mydata), FILE_APPEND) ;
$applicationcheck = $twitter->buildOauth('https://api.twitter.com/1.1/application/rate_limit_status.json', $requestMethod)
->performRequest();
$applicationstatus = json_decode($applicationcheck,true);
$appreset =$applicationstatus["resources"]["followers"]["/followers/list"]["reset"];
$appremaining = $applicationstatus["resources"]["followers"]["/followers/list"]["remaining"];
if ($appremaining <= 2) {
print_r($applicationstatus["resources"]["followers"])."\n\n";
echo "Rate Limit Execeed- 15 minute (900 seconds) countdown begins:" . "\n\n";
$n = 0;
if ($n<2) {
for($i = 901; $i > 0; $i--)
{
echo $i;
sleep(1);
echo " \\\\ ";
}
echo "\n\n\n"."Thanks For Your Patience!"."\n\n";
echo "\n\n\n"."The Reset Time for Your App is ".$appreset."\n\n";
echo "\n\n\n"."The Remaining Calls before the next reset is ".$appremaining--."\n\n";
$n++;
echo "Number of Times the application has tried to re-run is : " . $n ."\n\n";
continue;
}
}
} while ($status != 429);
?>