-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchusers.php
80 lines (48 loc) · 1.91 KB
/
searchusers.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
<?php
require_once('twitter-api-php/TwitterAPIExchange.php');
$search_term = "maryland";
$page = 1;
$count = 1000;
$settings = array(
'oauth_access_token' => "811975859070443523-s3idYBSPXlzDvhqk5JqRJWnOHeQzeqA",
'oauth_access_token_secret' => "TmBiYjr26JBP2IZvtuDNEO15B0vZaDJSPCN9JFrr2hXg3",
'consumer_key' => "lKa06EW2OGOOXAsTffccUEYU1",
'consumer_secret' => "iLFJnZYfuMCH38Juum3orEAfX2QU4pMW4y5LAXlQgmfsd4uGFr"
);
$url = 'https://api.twitter.com/1.1/users/search.json';
$getfield = '?q='.$search_term.'&page='.$page.'&count='.$count;
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
//$mydata = json_decode($response,true);
$status = $twitter->getHttpStatusCode();
echo "Your search term : " . " " . $search_term . " ". " results from Twitter : " . "\n" ;
//echo $search_term."-".$page." ". "has printed". " ". "with a response code of: ".$status."\n";
do {
/*if ($status = 429) {
$applicationcheck = $twitter->buildOauth('https://api.twitter.com/1.1/application/rate_limit_status.json', $requestMethod)
->performRequest();
echo print_r(json_decode($applicationcheck,true))."\n";
echo "Rate Limit Execeed- 15 minute (900 seconds) countdown begins:" . "\n";
for($i = 900; $i > 0; $i--)
{
echo $i;
sleep(1);
echo " \\\\ ";
}
echo "0\nThanksForYourPatience!";
}*/
$url = 'https://api.twitter.com/1.1/users/search.json';
$getfield = '?q='.$search_term.'&page='.$page.'&count='.$count;
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
echo $search_term."-".$page." ". "has printed". " ". "with a response code of: ".$status."\n";
file_put_contents( $search_term."-".$page.".json", $response, FILE_APPEND);
$page++;
} while ($page != 900);
?>