Worm99
Power Member
- Jan 12, 2012
- 632
- 377
I'm trying to make a twitter api scraper for retweeters of a tweet
It's supposed to grab a number from csv file and place it into the url for the twitter app to grab.
And loop until it's done
What am I doing wrong?
PHP:
<?php
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "xxx",
'oauth_access_token_secret' => "xxx",
'consumer_key' => "xxx",
'consumer_secret' => "xxx"
);
$file = fopen("contacts.csv","r");
while(! feof($file))
{
$url = "https://api.twitter.com/1.1/statuses/retweets/" . fgetcsv($file) . ".json";
$requestMethod = "GET";
if (isset($_GET['user'])) {$user = $_GET['user'];} else {$user = "cnn";}
if (isset($_GET['count'])) {$count = $_GET['count'];} else {$count = 100;}
$getfield = "?screen_name=$user";
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
if($string["errors"][0]["message"] != "") {echo "<h3>Sorry, there was a problem.</h3><p>Twitter returned the following error message:</p><p><em>".$string[errors][0]["message"]."</em></p>";exit();}
foreach($string as $items)
{
echo $items['user']['screen_name']."<br />";
}
}
fclose($file);
?>
And loop until it's done
What am I doing wrong?