Michael Gaigg: Über UI/UX Design

26Jun0

Highlights of Week 25/2011

Posted by Michael Gaigg

18Mar0

Highlights of Week 11/2011

Posted by Michael Gaigg

Thanks to everybody that sent me link suggestions. Here the highlights for week 11/2011:

21Jan0

Including Tweets into your Webpage

Posted by Michael Gaigg

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!

Tagged as: , , , No Comments
18Jan0

Highlights of Week 02/2011

Posted by Michael Gaigg

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.

15Nov0

Highlights of Week 46/2010

Posted by Michael Gaigg

Anything I've missed?

Post it in the comments or drop me a note.

1Aug0

Highlights of Week 30/2010

Posted by Michael Gaigg

31Jan0

Highlights of Week 04/2010

Posted by Michael Gaigg