Buy Some Art!

Mailing List

Keep up with news and shows by signing up for my mailing list. All subscribe/unsubscribe requests must be confirmed via email.


Connect & Socialize

Interested in contacting me about a show opportunity or you have a question send me an email. Below are some places I visit frequently on the web.

Customizable Twitter Badge in PHP5

What’s Twitter? A global community of friends and strangers answering one simple question: What are you doing? Answer on your phone, IM, or right here on the web!

I wrote a script that uses the Twitter API to build a customizable twitter status badge. I’m pretty much a novice PHP programmer and this is the first piece of code I’m releasing. It should work fine on any PHP5 server. The script uses cURL to authenticate and grab the XML file from Twitter and then the XML is parsed using PHP5’s SimpleXML.

Enjoy -Rik!

Requirements:

PHP5 (*** Will Not Work in PHP4 ***)
Twitter Account

Directions:

Edit the badge_config.php file, supply your twitter username, twitter password, and how many status items you would like to show up. I think the Twitter API only allows a maximum of 20 items, but I could be wrong. Upload all files to your server running PHP5, then in a web browser goto your_folder_name/badge_template.php. If it showed up your good to go.

Demo:

My Twitter Badge

Files Included:

badge_config.php - Configuration file
badge_template.php - Sample Template
twitter.css - Templates CSS
TwitterBadge.php - TwitterAPI Class

Download:

twitterbadge.zip

10 People left comments

  • ↓   Wolf @ May 14th, 2007 at 7:09 am

    Awesome.

  • ↓   Quanmengli @ May 14th, 2007 at 8:24 am

    Trackback: RIKCAT - The Art of Rik Catlow - Customizable Twitter Badge in PHP5 Customizable Twitter Badge in PHP5 (tags: twitter php5 tools hacks) [...]

  • ↓   congkai @ June 4th, 2007 at 7:42 am

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in on line 18

    i recieved this error.. why?

    congkai@hotmail.com

  • ↓   congkai @ June 4th, 2007 at 7:52 am

    shit. i am using php 4.4.2… OH GOSH!! i am using php 4.. how to make it work?

  • ↓   Rik Catlow @ June 4th, 2007 at 8:00 am

    Congkai, The only way to get it to work is to re-write the xml parsing with XML_Parser.

  • ↓   Chris @ July 16th, 2007 at 9:38 pm

    Awesome, thanks! Thankfully my hosting service allows me to choose PHP 4 or 5 via the domain management control panel! Works beautifully. Integrates easily within my off-the-shelf blog software.

  • ↓   Luke Dorny @ July 31st, 2007 at 9:56 pm

    Very cool, Rik!
    Wonderfully done, and easy!
    Once my host gets up to php5, i’ll use this one instead of the blah one i use now… ;)

  • ↓   Donna Lin @ January 22nd, 2008 at 9:21 am

    Its very usefull.. Thanks.

  • ↓   Tom @ March 15th, 2008 at 12:39 pm

    I am trying to create a form field for my member’s site pages that will allow them to simply type in their Twitter username and the badge with css styled to my site will appear in an iframe. Will let you know how it work’s out. Since I am a novice php programmer/hacker (otherwise a PHP keyboard tuner), it should be fun to try to embed the Rikcat code into my existing site!

  • ↓   charles @ March 20th, 2008 at 1:01 am

    How to incorporate this to a widget in wordpress? I’m at lost.

Leave a Comment