function parseTwitterReply($messages){
$twitterReturn = new SimpleXMLElement($messages);
$i=0;
foreach($twitterReturn->status as $status){
$updateTime[$i]=$status->created_at;
$update[$i]=$status->text;
$profile_image_url[$i] = $status->user->profile_image_url;
$screen_name[$i] = $status->user->screen_name;
$i++;
}
$parsedReturn = array();
$parsedReturn['updateTime']=$updateTime;
$parsedReturn['update']=$update;
$parsedReturn['profile_image_url']=$profile_image_url;
$parsedReturn['screen_name']=$screen_name;
return $parsedReturn;
}
function call_timeline($messages) {
$twitterReturn = new SimpleXMLElement($messages);
$i=0;
foreach($twitterReturn->status as $status) {
$updateTime[$i] = parseDate($status->created_at);
$update[$i] = $status->text;
$profile_image_url[$i] = $status->user->profile_image_url;
$screen_name[$i] = $status->user->screen_name;
$i++;
}
$parsedReturn = array();
$parsedReturn['updateTime']=$updateTime;
$parsedReturn['update']=$update;
$parsedReturn['profile_image_url']=$profile_image_url;
$parsedReturn['screen_name']=$screen_name;
return $parsedReturn;
}
function getTwitterData($command) {
global $twitter;
switch ($command) {
case 'timeline':
{ $messages=$twitter->getHomeTimeline('xml');
return call_timeline($messages);
}
break;
case 'mentions':
{ $messages=$twitter->getMentions('xml');
return call_timeline($messages);
}
break;
case 'direct':
{ $messages=$twitter->getMessages('xml');
return call_direct($messages);
}
break;
}
function getHomeTimeline($format, $id=NULL, $count = 60, $since = NULL) {
if ($id != NULL) {
$api_call = sprintf("statuses/home_timeline/%s.%s", $id, $format);
}
else {
$api_call = sprintf("statuses/home_timeline.%s", $format);
}
if ($since != NULL) {
$api_call .= sprintf("?since_id=%s", urlencode($since));
$count=0;
}
if ($count != 60 AND $count !='') {
$api_call .= sprintf("?count=%d", $count);
}
return $this->get($api_call);
}
}
?>