<?php
require("twitter.lib.php");


// let's clean up the slashes from the POSTed things we received.
$username tidyslashes($_POST['username']);
$password tidyslashes($_POST['password']);
$message tidyslashes($_POST['message']);


// what are we doing today?
switch($_POST['type']) {
  case 
'update':
     
update();
     break;
  case 
'public':
     
getpublictimeline();
     break;
  case 
'friends':
     
getfriends();
     break;
  default:
     die(
"died: not called properly");
     break;
}


// functions follow

function tidyslashes($text) {
    if (
get_magic_quotes_gpc()) {
        
$cleantext stripslashes($text);
    }
    else {
        
$cleantext $text;
    }
    return 
$cleantext;
}


function 
update() {
  global 
$username$password$message;
  
$twitter = new Twitter($username$password);
  
$update $twitter->updateStatus($message);
  
print_r($update);
}


function 
getfriends() {
  global 
$username$password;
  
$twitter = new Twitter($username$password);
  
$friends $twitter->getFriendsTimeline(array('format' => 'xml'));
  
print_r($friends);

}

function 
getpublictimeline() {
  global 
$username$password;
  
$twitter = new Twitter($username$password);
  
$getpublictimeline $twitter->getPublicTimeline(array('format'=>'xml'));
  
print_r($getpublictimeline);
}

?>