Twitter Class for PHP

David Billingham has put together an awesome PHP class full of Twitter functions:He provides a few examples of usage in the source file. Here’s an example of using the class to post a direct message with a little extra error output:

$message = “your direct message”;
$t= new twitter();
$t->username= “yourtwitterusername”;
$t->password= “yourtwitterpassword”;
$res = $t->sendDirectMessage(“directmsgrecepient,$message);
if($res===false){ //if there is a Twitter error
echo ‘<span class=”style7”>Something went wrong!</span> <br/>Twitter said: <span class=”style5”>’ . $t->errmsg . ‘</span><br/> Please try again.’;
}else{
echo ‘<span class=”style3”>SUCCESS!! TWEET SENT!</span><br/>’;}

Hi there, I'm Jon.

Writer. Musician. Adventurer. Nerd.

Purveyor of GIFs and dad jokes.