Skip to content

Instantly share code, notes, and snippets.

@collegeman
Created February 25, 2011 19:22
Show Gist options
  • Save collegeman/844333 to your computer and use it in GitHub Desktop.
Save collegeman/844333 to your computer and use it in GitHub Desktop.
Sampling Twitter stream
<?php
$keyword = '';
$username = '';
$password = '';
$ch = curl_init("http://stream.twitter.com/1/statuses/filter.json?track={$keyword}");
curl_setopt_array($ch, array(
CURLOPT_READFUNCTION => 'read_twitter_stream',
CURLOPT_USERPWD => '{$username}:{$password}',
CURLOPT_TIMEOUT => 0
));
curl_exec($ch);
function read_twitter_stream($ch, $data) {
echo $data;
return strlen($data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment