Skip to content

Instantly share code, notes, and snippets.

@hubgit
Last active August 29, 2015 14:05
Show Gist options
  • Save hubgit/146530312e3f6c860a8f to your computer and use it in GitHub Desktop.
Save hubgit/146530312e3f6c860a8f to your computer and use it in GitHub Desktop.
Stream filtered tweets into dat
  1. sudo aptitude install git php5-cli nodejs
  2. npm install -g npm
  3. npm install -g maxogden/dat
  4. dat init
  5. dat listen
  6. Create a Twitter application and generate OAuth keys for your user - add the app and user credentials to stream.php.
  7. composer init && composer require fennb/phirehose:dev-master && composer install
  8. php stream.php | dat import -json
  9. Install and start dat-editor then open dat-editor to browse the table.
<?php
require __DIR__ . '/vendor/autoload.php';
class FilterTrackConsumer extends OauthPhirehose {
public function enqueueStatus($status) {
print $status . "\n";
}
}
// Application OAuth credentials
define('TWITTER_CONSUMER_KEY', '***');// "API key"
define('TWITTER_CONSUMER_SECRET', '***'); // "API secret"
// User OAuth credentials
define('OAUTH_TOKEN', '***'); // "Access token"
define('OAUTH_SECRET', '***'); // "Access token secret"
// start streaming
$consumer = new FilterTrackConsumer(OAUTH_TOKEN, OAUTH_SECRET, Phirehose::METHOD_FILTER);
$consumer->setLang('en');
$consumer->setTrack(array('wikipedia'));
$consumer->consume();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment