Skip to content

Commit

Permalink
Add mandatory Twitter credentials check to Collector
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Phelps <andrew@phel.ps>
  • Loading branch information
phelps committed Jul 28, 2013
1 parent 79a05d9 commit 11198ce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion collect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OpenFuego\app\Universe as Universe;
use OpenFuego\app\Collector as Collector;
use OpenFuego\lib\Logger as Logger;
use OpenFuego\lib\TwitterHandle as TwitterHandle;

if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
die(__NAMESPACE__ . ' requires PHP 5.3.0 or higher.');
Expand All @@ -29,6 +30,15 @@
Logger::fatal(__NAMESPACE__ . " collector was terminated.");
});

$twitter = new TwitterHandle();
$twitter->get("account/verify_credentials", array("include_entities" => 0, "skip_status" => 1));
if ($twitter->http_code !== 200) {
$error_message = "Cannot continue. Your Twitter credentials appear to be invalid. Error code {$twitter->http_code}";
Logger::info($error_message);
die($error_message);
}
unset($twitter_handle);

$authorities = unserialize(\OpenFuego\AUTHORITIES);

$universe = new Universe();
Expand All @@ -46,7 +56,7 @@
}

$citizens = array_slice($citizens, 0, TWITTER_PREDICATE_LIMIT);

// Start streaming/collecting
$collector = new Collector(TWITTER_OAUTH_TOKEN, TWITTER_OAUTH_SECRET);

Expand Down

0 comments on commit 11198ce

Please sign in to comment.