Including Tweets into your Webpage
Very simple and effective. I started off researching into php libraries for twitter before I settled on a very pragmatic approach which I'd like to share here. I separated the code into smaller bits for clarity and better understanding.
Somewhere in your code include this HTML snippet (style the HTML using CSS id selectors):
<div id="twitter-container"> <div id="twitter-container-content"> <!-- tweet retrieval in here --> </div> </div>
Copy and paste the actual PHP tweet retrieval code into the section above. Don't forget to rename the screen_name to whatever your twitter handle is
print("<h2>Latest Tweets</h2>"); error_reporting(-1); ini_set('display_errors', true); $user = new SimpleXMLElement('http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=michaelgaigg&count=3',null,true); foreach($user->status as $status){ print("<div class=\"twitter-entry\">"); print("<div class=\"twitter-entry-text\">".renderUrls($status->text)."</div>"); print("</div>"); }
Add this PHP helper function (maybe you have a tools class) that will parse the tweet and detect hyperlinks which are then wrapped into the HTML A tag so that they become clickable.
function renderUrls($originalString) { $returnString = ""; $stringToArray = explode(" ",$originalString); foreach($stringToArray as $key=>$val) { //$URL_Validation = ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$", $val, $trashed); $returnString .= (substr($val,0,7) == "http://") ? "<a href='".$val."' target='_blank'>".$val."</a> " : $val." "; } return $returnString; }
That's it, no magic!
Highlights of Week 02/2011
Happy New Year and welcome back. After a wonderful family vacation in Austria, Europe (and white Christmas) I'm back and pleased to share my insights and what I'm learning for myself on a daily basis with you. As always, if you have an interesting article or link you want to bring to my attention, post it in the comments or tweet @michaelgaigg.
- 7 Essential Red Flags to Watch Out for in New Clients (by John O’Nolan) - look out for these red flags, they really can turn your job into a nightmare.
- Blogging Maps: The Design Galaxy (by BuySellAds) - discovert the galaxy of design in this interactive map.
- 10 Practical Ways to Bust Through Web Designer’s Block (by Sacha Greif) - Some nice tips what you can do when your brain is fried
- Christmas Design Resources: Santa Claus (by Bellefoong) - plenty of the good stuff here.
- 7 Tips for Building a Better Branded App (by Sarah Kessler) - Branding is important and Sarah offers some really nice tips.
- 10 Ideas for Creating Innovative and Unique Web Designs (by Jason Gross) - keep the ideas popping.
- Debunking User Experience (by Dean Schuster) - You can do it! Have a read..
- 10 Things You Can Do to Become a Better PHP Developer (by Raphael Caixeta) - use a PHP framework? uhm, yeah, right! coulda, shoulda..
Highlights of Week 46/2010
- 10 Intermediate and Advanced Tips from PHP Masters (by Jolie O'Dell) - experts offer their advise; nice compilation.
- Beautiful (Free) Fonts for Titles and Headlines (by bellefoong) - niiice.
- Ways to Horrify Website Designers (by Alexander Dawson) - right in time for Halloween
- Design is Choice (by Dmitry Fadeyev) - Dmitry's take on Google removing the "http://" portion in Chrome's address bar
- The Seven Deadly Sins of Design (by Rob Bowen) - a funny take on seven deadly sins.
- Google Chrome Extensions for Web Design Students (by Julia May ) - Ctrl/Cmd + Shift + J ... that's all I say...
- How to Design the Perfect Business Card (by Rob Bowen) - Great article that serves as categorization and motivation at the same time.
- jQuery 1.4.4 Released (by Addy Osmani) - may I introduce: .fadeToggle() - with 1.5 coming next year.
Anything I've missed?
Post it in the comments or drop me a note.
Highlights of Week 30/2010
- How Web Designers Can Adopt a Global Mindset (by Christian Arno) - Cultural differences are shamelessly overlooked, depending on your audience that might be ok but you should know... read the article.
- User Interface Design Framework (by webalys) - a really nice set of flexible GUI elements, free icon library and a graphic style library.
- The Hackday Toolbox – getting you started faster (by Chris Heilmann) - wow, what a great set of resources to get you started with YQL for PHP and JavaScript.
- How to Navigate Design by Committee (by Andrew Follett) - Andrew outlines a feasible approach to steering design discussions into a successful direction.
- Accessiblity Forum 2.0 (by buyaccessible.net) - promising blog to follow if you are into accessibility.
- 10 Free Online Books for Web Designers (by Henry Jones) - add to your never ending supply of good stuff.

