<?php
 
// to use make sure script is in location allowed by open_basedir and
 
// use command "php pulldata.php %username%"
 
// where username is set to the twitter user name
 
require_once("classes.php");
 
// get the username form the commandline paramters
 
$username = $argv[1];
 
 
// create a new instance of the TwitterFeedAPI class
 
$twitterAPI = new TwitterFeedAPI();
 
 
// pass the required username to the instance of TwitterFeedAPI
 
$twitterAPI->setUsername($username);
 
 
// create the start task to open the output file
 
$startTaskId = $twitterAPI->setStartTaskFunction(function(){
 
    $GLOBALS['fileHandle'] = fopen($username."txt", 'w');
 
});
 
 
// create the end task to close the output file
 
$endTaskId = $twitterAPI->setEndTaskFunction(function(){
 
    fclose($GLOBALS['fileHandle']);
 
});
 
 
// create the task to use the output file and write the tweet to it
 
$eachTweetID = $twitterAPI->setEachTweetFunction(function($tweet){
 
    fwrite($GLOBALS['fileHandle'], $tweet->text."\r\n\r\n");
 
});
 
 
// tell the API to download the API responce
 
// this can be rapped in error checking as it can throw TwitterConnectionFailedException
 
$twitterAPI->fetch_tweets();
 
 
// tell the API to begin the parser
 
// this can be rapped in error checking as it can throw TwitterErrorException
 
$twitterAPI->parse();
 
 
// unset the functions
 
$twitterAPI->removeEachTweetFunction($eachTweetID);
 
$twitterAPI->removeStartTaskFunction($startTaskId);
 
$twitterAPI->removeEndTaskFunction($endTaskId);
 
?>
 
 |