Full Twitter PHP Library (Ver 0.1)
I have written a complete code library for twitter using PHP for an upcoming project I will be releasing soon.
Get the code here twitterPHP.
Methods
update($status)
publicTimeline($sinceid=false)
friendsTimeline($id=false,$since=false)
userTimeline($id=false,$count=20,$since=false)
showStatus($id)
friends($id=false)
followers()
featured()
showUser($id)
directMessages($since=false)
sendDirectMessage($user,$text)
Examples
Get the Public Timeline
$t= new twitter();
$res = $t->publicTimeline();
if($res===false){
echo "ERROR<hr/>";
echo "<pre>";
print_r($t->responseInfo);
echo "</pre>";
}else{
echo "SUCCESS<hr/>";
echo "<pre>";
print_r($res);
echo "</pre>";
}
Update your status (change username and password of course)
$t= new twitter();
$t->username='username';
$t->password='password';
$res = $t->update('i am testing twitter.class.php');
if($res===false){
echo "ERROR<hr/>";
echo "<pre>";
print_r($t->responseInfo);
echo "</pre>";
}else{
echo "SUCCESS<hr/>Status Posted";
}
Let me know what you think or if you find this useful.

awesome, I will test it for an upcoming project of mine.
cool stuff thanks
nice but not usable for php4, perhaps its better not to provide an object in php5 and an xml file in php4.
create an array to use in both php versions.
Wow…this is so cool…thank you for sharing this …I’m definately going to steal..err..use these ideas….I’m looking at something easier for my Blackberry…i don’t like the Java apps..they hang all the time!
Can’t wait to see what your project is.
thanks for sharing.
Andy Bilodeau
http://andy.andycast.net
PHP XML Parser for Twitter…
Mich hat es mal wieder gereizt etwas PHP zu programmieren. Aus diesem Grund wollt ich mal versuchen ein Serendipity Plugin zu schreiben. Naheliegend für mich war und ist ein Twitter Sidebar Plugin und die ersten Erfolge sind schon zu verzeichnen David…
so I addes a new feature to the class of david, its not completed yet but already works for some twitter features.
now you are able to get the xml response as a array - and now you can work with this class in an easy way using php4.
blogged it here and try to get in contact with david
http://blog.gotchi.at/archives/451-PHP-XML-Parser-for-Twitter.html
sorry is in german, I will definitly write a english version when the class is finished and is working as expected
ne version, now blog entry in english and german
http://blog.gotchi.at/archives/460-PHP-XML-Parser-for-Twitter.html
Why didn’t you documented it in PhpDoc (or similar) format ? Don’t be lazy, it’s easy!
Good luck for the project.
[...] easy to use class wrappers for the APIs it was a piece of cake. I used easy scrobbler, phpFlickr, this Twitter library (with some cURL modifications so it’d run on Dreamhost) and SimplePie for the other RSS [...]
this is excellent code mate, well done. Its above my level of php atm, but not for long :p thanks for proverbially flicking my brain into action again.
Great code!!
I have got this working on my site at:
http://www.artifacting.com/python-twitter/tttwitter.php
Unfortunately it doesn’t look very pretty could you help me out with how with the aesthetics?
thanks for your help