<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jesus Presleys Life Spam &#187; php</title>
	<atom:link href="http://www.jesuspresley.net/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jesuspresley.net/blog</link>
	<description>Music, the web and some eye candy. News on viral media, open source gadgets and artsy fartsy visuals</description>
	<lastBuildDate>Tue, 18 Aug 2009 19:49:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>de</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Example usage of Twitter API with source code</title>
		<link>http://www.jesuspresley.net/blog/example-usage-of-twitter-api-with-source-code/</link>
		<comments>http://www.jesuspresley.net/blog/example-usage-of-twitter-api-with-source-code/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 17:32:50 +0000</pubDate>
		<dc:creator>Jesus Presley</dc:creator>
				<category><![CDATA[opensource]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.jesuspresley.net/blog/?p=472</guid>
		<description><![CDATA[I have now, finally, succeeded to get into working with the twitter API - one of the most popular around.
I am impressed by the possibilities and will try more. This is a little script that I startes following an introduction printed in German PHP Magazin.The layout needs some finetuning, but it works really well. I [...]]]></description>
			<content:encoded><![CDATA[I have now, finally, succeeded to get into working with the <em>twitter API</em> - one of the most popular around.
I am impressed by the possibilities and will try more. This is a little script that I startes following an introduction printed in German <em><a href="http://it-republik.de/php/php-magazin-ausgaben/JavaScript-mit-jQuery-000285.html">PHP Magazin</a></em>.<br/>The layout needs some finetuning, but it works really well. I will keep you updated when I modify it.
<br/>This post might be interesting for you...<br/><br/>
<ul>
	<li>if you are an beginner or intermediate php developer looking for a base where to start coding your own twitter display.</li>
	<li>if you are already experienced in copy &#038; pasting php code into your wordpress blog, for example, expanding the functionality of your sidebar or your page template</li>
</ul><br/>
The Twitter API provides JSON technology and can be accessed by the cURL command. The PHP version you therefore need is 5.2 and above.<br/>
I you like to work with this code, copy and paste it into a page on your blog or other php enabled website.<br/><strong>Caution: </strong>You need to have the <a href="http://wordpress.org/extend/plugins/exec-php/">Exec-PHP</a> plugin installed in order for the code to be executed. The additional CSS definitions might scramble the display of your website layout, so consider to modify it if needed.<br/>
Does anyone know a workaround for this?<br/>To get the plain php code, click on "view plain" above the code display.
<br/><br/>
<ul>
	<li><a href="http://www.jesuspresley.net/blog/twt/">This is how it looks</a></li>
</ul><br/>
Notice: Twitter only allows 100 updates per hour, so the timeline display might be empty during heavy traffic.<br/>
Now have fun with the code:
<br/><br/>
<pre name="code" class="php">
&lt;?php
// functions
function gradientHexBGcolor($k=6){
return sprintf("%02X%02X%02X", 29+$k*18, 9+$k*20,9+$k*20);
}
function gradientHexFGcolor($k=6){
return sprintf("%02X%02X%02X", 260-$k*5, 260-$k*5,260-$k*5);
}

// Init Data
$fill = '';
$thisPage = $_SERVER['REQUEST_URI'];

//Enter your Twitter data here:
$twitName = "MyTwitterUsername";
$twitPass = "MyTwitterPassword";
$twitUserDataURL = "http://twitter.com/users/show/MyTwitterUsername.json";
$twitGetURL = "http://twitter.com/statuses/friends_timeline.json";

// Check if a hashtag was given?

if (!$_POST['hashtag']) {
		$fill = 'Enter hashtag here...';
		}
		else {
		$tag = $_POST['hashtag'];
		$twitGetURL = "http://search.twitter.com/search.json?q=%23".$tag;		
		}

// cURL 1: get Userdata:
// Init cURL
$curl = curl_init();
// set Userdata URL
curl_setopt($curl,CURLOPT_URL,$twitUserDataURL);
// prepare for return values
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
// set authentification
curl_setopt($curl,CURLOPT_USERPWD,"$twitName:$twitPass");
// get + decode return values
$returnUser = json_decode(curl_exec($curl));
// close cURL
curl_close($curl);

// cURL 2: get timeline or tag search data:
// Init cURL
$curl = curl_init();
// set URL
curl_setopt($curl,CURLOPT_URL,$twitGetURL);
// prepare for return values
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
// set authentification
curl_setopt($curl,CURLOPT_USERPWD,"$twitName:$twitPass");
// get + decode return values
$return = json_decode(curl_exec($curl));
// close cURL:
curl_close($curl);		

// define &#038; output css style definitions:
echo '&lt;style type="text/css"> 
 					div, .twitapi a, p, span, table, td, input, textarea, b, blockquote, th, form {font-family:Tahoma,Trebuchet MS,Arial,sans-serif;font-size:8pt;border:0;margin:0;padding:0;line-height:140%;}				
					div.twitapi {width:540px;background:#CDCDCD;padding:6px 0;}	
					.twitapi p, .twitapi br {display:none;}	
					.twitapi hr {border:0;border-top:1px dotted #FFF;}		 	
					.twitapi table {#position:relative;border:0;border-collapse:collapse;width:100%;}	
					.twitapi table td {width:50%;border:0;padding:0;overflow:hidden;}
 					pre {color:#000;text-decoration:none;border:0;margin:0;padding:0;} 		
					.twitapi a, .twitapi img,.twitapi span,.twitapi div {color:#FFF;text-decoration:none;border:0;margin:0;padding:0;} 
					div.outer {margin:6px 3%;padding:0;width:94%;}					
					div.wrap {#position:relative;display:table;height:48px;text-align:left;margin:6px 3%;padding:0;width:94%;}
					div.text {#position:absolute;#top:50%;display:table-cell;vertical-align: middle;padding:0;}	
					.twForm {color:#FFF;padding:0;}									
					.twForm span {display:block;height:24px;margin:0;padding:0;overflow:hidden;}	
 					.twForm input, button, textarea, select {width:100%;height:100%;border:0;padding:5px;color:#FFF;overflow:hidden;}
 					.twForm .button {text-align:right;}	
 					.twForm .button:hover {color:#'.gradientHexBGcolor(7).';}	 					
 					.twForm textarea {font-weight:bold;}					 				 				 													
					div.inner {#position:relative;#top:-50%;overflow:auto;margin:0 10px;}		
					a.img {display:inline;float:left;width:48px;height:48px;overflow:hidden;}
					a.img img {width:48px;height:48px;border:0;}
					
  		&lt;/style>';


// output twitter container &#038; headline &#038; buttons
echo '&lt;div class="twitapi">
		&lt;div class="wrap" style="background-color:#'.gradientHexBGcolor().';">
		&lt;table>&lt;tr>&lt;td>
			&lt;a class="img" href="'.$returnUser->profile_image_url.'">&lt;img src ="'. $returnUser->profile_image_url.'">&lt;/a>
				
				&lt;form class="twForm"  action="" method="POST">&lt;input name="line" value="" type="hidden">		 
					&lt;span>&lt;textarea readonly style="background-color:#'.gradientHexBGcolor(6).';">'.$twitName.'\'s timeline&lt;/textarea>&lt;/span>	
					&lt;span>														
					&lt;input class="button" style="background-color:#'.gradientHexBGcolor(2).';" value="Refresh now!" type="submit">
					&lt;/span>				
				&lt;/form>	
				&lt;/td>	
				&lt;td>					
				&lt;form class="twForm" action="'.$thisPage.'" method="POST">	
					&lt;span>	
					&lt;input class="text" style="background-color:#'.gradientHexBGcolor(8).';" name="hashtag" value="'.$tag.$fill.'" type="text">
					&lt;/span>
					&lt;span>								
					&lt;input class="button" style="background-color:#'.gradientHexBGcolor(4).';"value="Search now!" name="submit" type="submit">
					&lt;/span>				
				&lt;/form>	
				&lt;/td>					
				&lt;/tr>&lt;/table>								
		&lt;/div>
		&lt;hr>';
	

// output tweets
// output friends' timeline if no hashtag given, else tweets with hashtag
if (!$tag) {
			foreach($return as $key=>$tweet) {
			if ($key&lt;=10) {		
					$text = $tweet->text;
					// Add links to URLS
					$text = ereg_replace("[[:alpha:]]+://[^&lt;>[:space:]]+[[:alnum:]/]","&lt;a href=\"\\0\" rel=\"nofollow\">\\0&lt;/a>", $tweet->text);
					// Add links to Twitterprofiles with @	
					$text = preg_replace("#(^|[\n ])@([^ \"\t\n\r&lt;]*)#ise", "'\\1&lt;a href=\"http://www.twitter.com/\\2\" >@\\2&lt;/a>'", $text); 
					// Add links to hashtags #	
					$text = preg_replace("#(^|[\n ])\#([^ \"\t\n\r&lt;]*)#ise", "'\\1&lt;a href=\"http://hashtags.org/search?query=\\2\" >#\\2&lt;/a>'", $text); 	 		 
					echo '&lt;div class="wrap" style="background-color:#'.gradientHexBGcolor($key).';">
					&lt;a class="img" href="http://twitter.com/'. $tweet->user->screen_name.'">&lt;img src ="'. $tweet->user->profile_image_url.'">&lt;/a>		
					&lt;div class="text">	
						&lt;div class="inner" color="#'.gradientHexFGcolor($key).'">					
					&lt;a href="http://twitter.com/'. $tweet->user->screen_name.'">'. $tweet->user->screen_name.'&lt;/a>: 
					'.$text.' >>'. $tweet->source.'&lt;/div>&lt;/div>&lt;/div>';
					}
			}
		} 		
		else {
			foreach($return->results as $key=>$tweet) {	
			if ($key&lt;=10) {				
						$text = $tweet->text;
						// Add links to URLS
						$text = ereg_replace("[[:alpha:]]+://[^&lt;>[:space:]]+[[:alnum:]/]","&lt;a href=\"\\0\" rel=\"nofollow\">\\0&lt;/a>", $tweet->text);
						// Add links to Twitterprofiles with @	
						$text = preg_replace("#(^|[\n ])@([^ \"\t\n\r&lt;]*)#ise", "'\\1&lt;a href=\"http://www.twitter.com/\\2\" >@\\2&lt;/a>'", $text); 
						// Add links to hashtags #	
						$text = preg_replace("#(^|[\n ])\#([^ \"\t\n\r&lt;]*)#ise", "'\\1&lt;a href=\"http://hashtags.org/search?query=\\2\" >#\\2&lt;/a>'", $text); 	 		 
						echo '&lt;div class="wrap" style = "background-color:#'.gradientHexBGcolor($key).';">
						&lt;a class="img" href="http://twitter.com/'. $tweet->from_user.'">&lt;img src ="'. $tweet->profile_image_url.'">&lt;/a>				

						&lt;div class="text">	
						&lt;div class="inner" color="'.gradientHexFGcolor($key).'">&lt;a href="http://twitter.com/'. $tweet->from_user.'">'. $tweet->from_user.'&lt;/a>: 
						'.$text.' at '. date('M d,Y',strtotime($tweet->created_at)).'&lt;/div>&lt;/div>&lt;/div>';
						}
			}			
		}		


echo '&lt;/div>';
?>
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.jesuspresley.net/blog/example-usage-of-twitter-api-with-source-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sweetcron &#8211; Blogging 21st century style</title>
		<link>http://www.jesuspresley.net/blog/sweetcron-blogging-21st-century-style/</link>
		<comments>http://www.jesuspresley.net/blog/sweetcron-blogging-21st-century-style/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:24:53 +0000</pubDate>
		<dc:creator>Jesus Presley</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[friendfeed]]></category>
		<category><![CDATA[lifestream]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[sweetcron]]></category>
		<category><![CDATA[tumbl. flickr]]></category>

		<guid isPermaLink="false">http://www.jesuspresley.net/blog/?p=300</guid>
		<description><![CDATA[Sweetcron is a service that brings you the features of friendfeed and tumblr. Apart from the fact that it&#8217;s build for being hosted at your own web server. Kind of a wordpress for feeds. Check the developers site yongfook.com for a working demo blog.
Update: Sweetcron Beta is out for evaluating:

Sweetcron program files
Seetcron documenatation



It&#8217;s closed beta [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sweetcron.com/">Sweetcron</a> is a service that brings you the features of <a href="http://friendfeed.com/">friendfeed </a>and <a href="http://www.tumblr.com/">tumblr</a>. Apart from the fact that it&#8217;s build for being hosted at your own web server. Kind of a wordpress for feeds. Check the developers site <a href="http://www.yongfook.com">yongfook.com</a> for a working demo blog.</p>
<p>Update: Sweetcron Beta is out for evaluating:</p>
<ul>
<li><a href="http://code.google.com/p/sweetcron/downloads/list">Sweetcron program files</a></li>
<li><a href="http://code.google.com/p/sweetcron/w/list">Seetcron documenatation</a></li>
</ul>
<p><a href='http://www.yongfook.com'><img src="http://www.jesuspresley.net/blog/wp-content/uploads/2008/08/screenshot015250808.png" alt="" title="Sweetcron is free and open source lifestream software" class="alignnone size-full wp-image-302" /></a></p>
<p><object width="540" height="451"><param name="movie" value="http://www.youtube.com/v/VqFd6EDQimU&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/VqFd6EDQimU&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="540" height="451"></embed></object></p>
<p>It&#8217;s closed beta right now, but the developer, Yongfook, promises to launch it soon. It is going to be 100% open source and offers some more features:</p>
<ul>
<li>Automated Imports: Uploaded a photo to flickr? Bookmarked a new site? In a few minutes it will show up on your blog, thanks to the power of RSS feeds</li>
<li>Easily Customisable: Edit simple templates to change your Sweetcron look.</li>
<li>Self Hosted: You can keep alll the data safely on your own server and run Sweetcron on your own domain.</li>
<li>Fully extensible: Write your own php classes and slot them right in!</li>
</ul>
<p>Check the <a href="http://lifestreamblog.com/interview-with-yongfook-on-sweetcron-automated-lifestream-blog-software/">Interview with Yongfook</a> on Lifestreamblog.com</p>
<p>via <a href="http://t3n.yeebase.com/aktuell/news/newspost/sweetcron-beta-der-open-source-lifestream-plattform-veroeffentlicht/1893/">t3n</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jesuspresley.net/blog/sweetcron-blogging-21st-century-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
