<?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>Web &#124; SaaS Developer (PHP, Mysql, Apache) LAMP Developer</title>
	<atom:link href="http://dizzytree.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dizzytree.com</link>
	<description>Web &#124; SaaS Developer (PHP, Mysql, Apache) LAMP Developer</description>
	<lastBuildDate>Fri, 15 Jan 2010 13:20:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building a PHP Twitter Client</title>
		<link>http://dizzytree.com/2010/01/building-a-php-twitter-client/</link>
		<comments>http://dizzytree.com/2010/01/building-a-php-twitter-client/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:24:09 +0000</pubDate>
		<dc:creator>Brad Madigan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Arc90]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[TwitterAPI]]></category>

		<guid isPermaLink="false">http://localhost:8888/wp-demo/?p=109</guid>
		<description><![CDATA[In this tutorial we will be creating a quick and simple Twitter Update Manager as well as a Client that will can be published on your website or blog displaying your latest tweets.
At the heart of this code, is a third-party Twitter API Client developed by Arc90. They have been gracious enough to allow the [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial we will be creating a quick and simple <strong>Twitter Update Manager</strong> as well as a <strong>Client</strong> that will can be published on your website or blog displaying your latest <strong>tweets</strong>.</p>
<p><span id="more-109"></span>At the heart of this code, is a third-party <a title="Arc90 Twitter API Client" href="http://lab.arc90.com/2008/06/03/php-twitter-api-client/" target="_blank">Twitter API Client</a> developed by <a title="Arc90" href="http://www.arc90.com" target="_blank">Arc90</a>. They have been gracious enough to allow the rest of us, to use of their Code library. You will want to first of all download this library to your system. You should also note, that this tutorial is not an <a title="OAuth" href="http://oauth.net/" target="_blank">OAuth</a> tutorial. That may be covered in a later tutorial.</p>
<p><a rel="lightbox[Sample Twitter Client App]" href="/wp-content/uploads/2010/01/twitter-manager.png"><img class="aligncenter size-medium wp-image-144" title="Sample Twitter Client Application" src="/wp-content/uploads/2010/01/twitter-manager-244x300.png" alt="sample twitter client" width="244" height="300" /></a></p>
<p>As you can see from the above screenshot, the small app we will be creating will display three of your latest tweets, as well as a form below the tweets that will allow you to update a new twitter message.</p>
<h2>Download Code:</h2>
<pre class="brush: java">
$&gt;mkdir twitter-client
$&gt;cd twitter-client
$&gt;git clone git://github.com/dizzytree/PHP-Twitter-Client.git
</pre>
<p><span style="color: #ffcc99;">NOTE: You can choose to Install GIT or you can download a zip/tar from the the GitHub site.<br />
Here is the link to the <a title="Download Code from GITHub" href="http://github.com/dizzytree/PHP-Twitter-Client" target="_blank">direct download page</a>.<br />
Here is a link to install GIT on <a title="Install GIT on Mac OSX " href="http://help.github.com/mac-git-installation/" target="_blank">Mac OSX</a></span></p>
<h2>Directory Structure</h2>
<p>Before, we can start the actual coding, here is the directory structure will will need to create in order to proceed.</p>
<p><img class="aligncenter size-full wp-image-156" title="Application Folder Structure" src="/wp-content/uploads/2010/01/folder-structure.png" alt="" width="194" height="164" /></p>
<p><span style="color: #ffcc99;">NOTE: Arc90_Service_Twitter requires PHP 5.1.4 or later and libcurl 7.10.5 or later. Also note that the source code includes a file called info.php which will allow you to view your version of PHP and if you have LIBCURL installed. Also important to note, I tried using the latest ver 2.2.3 and I could not get the api to work. I had to use <a title="Arc90 Twitter API Code" href="http://code.google.com/p/arc90-service-twitter/downloads/list" target="_blank">2.2.0</a>.  This version is included with the source code below.</span></p>
<p><a href="/wp-content/uploads/2010/01/phpinfo.png" rel="lightbox[109]"><img class="aligncenter size-medium wp-image-155" title="Sample PHPINFO" src="/wp-content/uploads/2010/01/phpinfo-300x83.png" alt="" width="300" height="83" /></a></p>
<h2>Setup the config.php</h2>
<pre class="brush: php">

&lt;?php
/*
|---------------------------------------------------
| SAMPLE CONSTANT / CONFIG VARIABLES
|---------------------------------------------------
*/
define(&#039;TWITTER_USER&#039;,        &#039;username&#039;);
define(&#039;TWITTER_PASS&#039;,        &#039;password&#039;);

// Utility Function
// Reads in a Twitter Msg and returns properly formatted URLS and Hashes
function format_tweet($str)
{
// function code removed to save space.
// Refer to downloadable code
}

// Elapsed Time for query updates
function get_elapsedtime($time)
{
// function code removed to save space.
// Refer to downloadable code
}
</pre>
<p>There are only two constant variables that we will need to be concerned about;</p>
<ol>
<li>Your <strong>Twitter Username </strong>and</li>
<li>Your <strong>Twitter Account Password</strong>.</li>
</ol>
<p>Just replace these variables with your own, and you'll be all set to use the Twitter API.</p>
<p>Located within the config.php file are two utility functions. These functions are used for parsing your twitter feed as well as giving the twitter timestamp a more user friendly string. I removed the code for these function above to save some space.</p>
<h2>Create the twitter.php File</h2>
<pre class="brush: php">
&lt;?php
// Set the path as per Arc90 Lab Documentation
ini_set(&#039;include_path&#039;, &#039;arc90_service_twitter/lib&#039;);
</pre>
<p>According the Arc90 documention, we must first set our PHP Path so it will know where to find the Arc90 library.</p>
<pre class="brush: php">
// Load configuration file
require_once(&#039;config.php&#039;);
// Load Arc90 Twitter Class
require_once &#039;Arc90/Service/Twitter.php&#039;;
</pre>
<p>Secondly, we must load our configuration files.</p>
<pre class="brush: php">
/* Response format. */
$format = &#039;json&#039;;

// Create the Twitter Object
$twitter = new Arc90_Service_Twitter(TWITTER_USER, TWITTER_PASS);
</pre>
<p>In this example, we are going to use the <a href="http://php.net/manual/en/book.json.php">JSON</a> format for all incoming tweets. We will also need to create our Twitter Service Object.</p>
<h2>Create A New Twitter Message (twitter.php)</h2>
<pre class="brush: php">
// ------- POST A NEW TWITTER MSG
// -----------------------------------------------------
if(array_key_exists(&#039;text&#039;, $_POST))
{
$msg = $_POST[&#039;text&#039;];
$twitter-&gt;updateStatus($msg);
header(&#039;location: index.php&#039;);
exit();
}
</pre>
<p>If a user submits the form, the above code checks that the <span style="color: #c0c0c0;">'text'</span> input field exists. In your code, it may be a good idea to make sure that this field is not blank.</p>
<p>The text field data is then saved to $msg and then passed to the <span style="color: #c0c0c0;">updateStatus($msg)</span> function. And that's it! The user is then redirected to the index page and should be able to view their new tweet.</p>
<h2>View Twitter Messages</h2>
<pre class="brush: php">
// ------- GET THE TWITTER TIMELINE
// -----------------------------------------------------
$reply = $twitter-&gt;getUserTimeline($format);

if($reply-&gt;isError())
{
$tweet_status = &#039;&lt;h3&gt;Twitter Error&lt;/h3&gt; Sorry. Twitter is currently experiencing some difficulties&#039;;
}
else
{
$rsReplies = json_decode($reply, true);

$i = 0;
$tweets = array();

foreach($rsReplies as $reply)
{
if($i &gt; 2) { break; } // Limit to 3 tweets
$formatted_tweet = format_tweet($reply[&#039;text&#039;]);

// Populate the array
$tweets[$i][&#039;tweet&#039;] 	= $formatted_tweet;
$tweets[$i][&#039;time&#039;] 	= get_elapsedtime(strtotime($reply[created_at]));

$i++;
}
}
</pre>
<p>Finally, the above code is what actually retrieves your twitter messages.</p>
<p>Using the 'format' we set earlier (JSON), the <span style="color: #c0c0c0;">$twitter-&gt;getUserTimeline($format)</span> retrieves your messages and then saves the results to the $reply variable. You can also use 'xml', 'rss', 'atom' for possible data formats.</p>
<p>If there were no errors reported, the system then decodes your JSON data into a PHP array. We then loop through the array (saving the required data into a new array called <span style="color: #c0c0c0;">$tweets</span>) limiting to three messages. You can also note that this is where the two utility functions from the <span style="color: #c0c0c0;">config.php</span> file are used.</p>
<p>If you want more than three messages, you can set the following line as follows:</p>
<p><span style="color: #c0c0c0;"> if($i &gt; 4) { break; } // Limit to 5 tweets </span></p>
<h2>Create the index.php</h2>
<p>The index.php file contains all the standard HTML and Javascript code. Basically, think of this file as the 'View' of your application.</p>
<pre class="brush: js">
&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;
function CountLeft(field, count, max) {
if (field.value.length &gt; max)
field.value = field.value.substring(0, max);
else
count.value = max - field.value.length;
}
&lt;/script&gt;
</pre>
<p>The Javascript code just basically calculates the number of characters that are left. We set this (below) to 140 characters to mimic Twitter's character limit.</p>
<pre class="brush: php">
&lt;?php if( ! empty($tweet_status)) { ?&gt;
&lt;div class=&quot;status&quot;&gt;&lt;?php echo $tweet_status; ?&gt;&lt;/div&gt;
&lt;?php } ?&gt;

&lt;?php foreach($tweets as $tweet) { ?&gt;
&lt;div class=&quot;tweet&quot;&gt;
&lt;div class=&quot;tweeticon&quot;&gt;&lt;img src=&quot;images/icon-tweet.png&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;tweetmsg&quot;&gt;&lt;?php echo $tweet[&#039;tweet&#039;]; ?&gt;
&lt;br/&gt;&lt;span class=&quot;datecreated&quot;&gt;&lt;?php echo $tweet[&#039;time&#039;]; ?&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;hr&quot;&gt;&lt;/div&gt;
&lt;?php } ?&gt;
</pre>
<p>In the twitter.php we did a check to see if the API replied with an error. If so, the code populated a variable called $tweet_status. If this variable is not blank, the error will be displayed to the user.</p>
<p>We then run the $tweets (remember it's an array from twitter.php) through a for loop. Within this loop, we can display each twitter message.</p>
<pre class="brush: html">

&lt;form method=&quot;post&quot; action=&quot;twitter.php&quot;&gt;
&lt;h1&gt;ADD A NEW MESSAGE&lt;/h1&gt;
&lt;input name=&quot;text&quot; class=&quot;tweettxt&quot; type=&quot;text&quot; maxlength=&quot;140&quot;
onKeyDown=&quot;CountLeft(this.form.text,this.form.left,140);&quot;
onKeyUp=&quot;CountLeft(this.form.text,this.form.left,140);&quot;&gt;
&lt;br/&gt;&lt;input readonly type=&quot;text&quot; name=&quot;left&quot; size=3 maxlength=3 value=&quot;140&quot; class=&quot;leftmsg&quot;&gt;characters left
&lt;br/&gt;&lt;input type=&quot;submit&quot; value=&quot;Tweet&quot; class=&quot;submit&quot;&gt;
&lt;/form&gt;
</pre>
<p>The above form passes only one form field to twitter.php; the $_POST['text'] variable. You will also notice how I implemented the Javascript function CountLeft within the code to display the number of characters left. One thing to note: the character counter wanted a form field with the name = 'left'. I didn't want it to look like a form field, so with some CSS magic, I removed the form field itself, so it just looks like a text string. You can see how I did that in the 'leftmsg' CSS class.</p>
<p>I urge to download the code from my <a title="Dizzytree Github " href="http://github.com/dizzytree/PHP-Twitter-Client" target="_blank">Git repository</a> and play around with it. Like I mentioned earlier, this tutorial doesn't access the <a title="OAuth" href="http://oauth.net/" target="_blank">OAuth library</a>, but I may do that in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://dizzytree.com/2010/01/building-a-php-twitter-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Portfolio - MyAlgomaU Portal</title>
		<link>http://dizzytree.com/2010/01/portfolio-myalgomau/</link>
		<comments>http://dizzytree.com/2010/01/portfolio-myalgomau/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:22:13 +0000</pubDate>
		<dc:creator>Brad Madigan</dc:creator>
				<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Dizzytree]]></category>
		<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[UI Design]]></category>

		<guid isPermaLink="false">http://localhost:8888/wp-demo/?p=107</guid>
		<description><![CDATA[MyAlgomaU - Staff / Student Portal
While working on a contract position with a local University, I was hired to develop a Student, Staff and Faculty Portal.

During this project all user interface design, HTML, CSS, PHP Portal (business logic) and database programming (Mysql) were completed entirely by me. The project also required access to dozens of [...]]]></description>
			<content:encoded><![CDATA[<h2>MyAlgomaU - Staff / Student Portal</h2>
<p>While working on a contract position with a local University, I was hired to develop a Student, Staff and Faculty Portal.<br />
<span id="more-107"></span></p>
<p>During this project all user interface design, HTML, CSS, PHP Portal (business logic) and database programming (Mysql) were completed entirely by me. The project also required access to dozens of JSON web service calls to the University's CRM system.</p>
<p><img class="aligncenter size-full wp-image-127" title="MyAlgomaU Dashboard" src="/wp-content/uploads/2010/01/myau-dashboard.jpg" alt="" width="560" height="483" /><br />
Requirements &amp; Solution:</p>
<ul>
<li>Secure Login using LDAP (MS Active Directory)</li>
<li>Student Application / Registration System (tied to CRM System)</li>
<li>Custom Email Broadcast System</li>
<li>Custom IT Helpdesk System</li>
<li>University Event's Calendar</li>
<li>Twitter API Integration</li>
<li>Student Recruitment System</li>
<li>Hiring Form Management System</li>
<li>Faculty Class List System</li>
</ul>
<div class="portfolio-thumb"><a rel="lightbox[Sample Helpdesk Ticket Form]"  href="/wp-content/uploads/2010/01/myau-createticket.jpg"><img src="/wp-content/uploads/2010/01/myau-createticket-150x150.jpg" alt="" title="MyAU - Create a Helpdesk Ticket" width="150" height="150" class="aligncenter size-thumbnail wp-image-133" /></a></div>
<div class="portfolio-thumb"><a rel="lightbox[Sample Helpdesk Ticket]"  href="/wp-content/uploads/2010/01/myau-ticket.jpg"><img src="/wp-content/uploads/2010/01/myau-ticket-150x150.jpg" alt="" title="MyAU - Helpdesk Sample Ticket" width="150" height="150" class="aligncenter size-thumbnail wp-image-134" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://dizzytree.com/2010/01/portfolio-myalgomau/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Portfolio - PlugMyEvent</title>
		<link>http://dizzytree.com/2010/01/portfolio-plugmyevent/</link>
		<comments>http://dizzytree.com/2010/01/portfolio-plugmyevent/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:16:53 +0000</pubDate>
		<dc:creator>Brad Madigan</dc:creator>
				<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Dizzytree]]></category>
		<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[UI Design]]></category>

		<guid isPermaLink="false">http://localhost:8888/wp-demo/?p=104</guid>
		<description><![CDATA[PlugMyEvent - Event Management System
PlugMyEvent is a web application that allows users to create and connect events to registrations. Users can create an event, import an invitation list and send out invites to these contacts about the upcoming event. The system integrates with the User's Paypal account for ticket revenue.

This project is another personal project [...]]]></description>
			<content:encoded><![CDATA[<h2>PlugMyEvent - Event Management System</h2>
<p><a href="http://www.plugmyevent.com" target="_blank">PlugMyEvent</a> is a web application that allows users to create and connect events to registrations. Users can create an event, import an invitation list and send out invites to these contacts about the upcoming event. The system integrates with the User's Paypal account for ticket revenue.<br />
<span id="more-104"></span></p>
<p>This project is another personal project that I worked on. The system uses CakePHP v1.2 as well as a Mysql database. All design, HTML, CSS and PHP logic were completed entirely by me.</p>
<p><img class="aligncenter size-full wp-image-105" title="pme-homepage" src="/uploads/2010/01/pme-homepage.jpg" alt="" width="560" height="502" /></p>
<p>Requirements &amp; Solution:</p>
<ul>
<li>Simple Public / Administration Web Interface</li>
<li>Online Payment Tracking (using Paypal)</li>
<li>Event Registration System</li>
<li>Pay-as-you-go business model</li>
<li>Email Notification System</li>
<li>CakePHP Framework (version 1.2)</li>
</ul>
<div class="portfolio-thumb"><a rel="lightbox[PME - Create An Event Form]" href="/wp-content/uploads/2010/01/pme-newevent.jpg"><img class="aligncenter size-thumbnail wp-image-137" title="PME - New Event Form" src="/wp-content/uploads/2010/01/pme-newevent-150x150.jpg" alt="" width="150" height="150" /></a></div>
<div class="portfolio-thumb"><a rel="lightbox[PME - Event Registrations Sample]" href="/wp-content/uploads/2010/01/pme-registrations.jpg"><img class="aligncenter size-thumbnail wp-image-139" title="PME - Event Registrations Sample" src="/wp-content/uploads/2010/01/pme-registrations-150x150.jpg" alt="" width="150" height="150" /></a></div>
<div class="portfolio-thumb"><a rel="lightbox[PME - Events]" href="/wp-content/uploads/2010/01/pme-events.jpg"><img class="aligncenter size-thumbnail wp-image-138" title="PME - Event Listings Sample" src="/wp-content/uploads/2010/01/pme-events-150x150.jpg" alt="" width="150" height="150" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://dizzytree.com/2010/01/portfolio-plugmyevent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Portfolio - Zavanda</title>
		<link>http://dizzytree.com/2010/01/portfolio-zavanda/</link>
		<comments>http://dizzytree.com/2010/01/portfolio-zavanda/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 21:21:24 +0000</pubDate>
		<dc:creator>Brad Madigan</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Dizzytree]]></category>
		<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[UI Design]]></category>

		<guid isPermaLink="false">http://localhost:8888/wp-demo/?p=39</guid>
		<description><![CDATA[Zavanda - Online Helpdesk System
Zavanda is a web application that was built using a proprietary PHP framework. The backend uses a Mysql database with a custom wrapper class to guard against sql injection attacks.

All user interface design, HTML, CSS, business logic and database programming were completed entirely by me. The entire project took 6 months [...]]]></description>
			<content:encoded><![CDATA[<h2>Zavanda - Online Helpdesk System</h2>
<p><a href="http://www.zavanda.com" target="_blank">Zavanda</a> is a web application that was built using a proprietary PHP framework. The backend uses a Mysql database with a custom wrapper class to guard against <a href="http://en.wikipedia.org/wiki/Sql_injection" target="_blank">sql injection attacks</a>.<br />
<span id="more-39"></span></p>
<p>All user interface design, HTML, CSS, business logic and database programming were completed entirely by me. The entire project took 6 months during my spare time.</p>
<p><img class="alignnone size-full wp-image-75" style="margin: 16px 0pt;" title="Zavanda.com Homepage" src="/wp-content/uploads/2010/01/port-zavanda-home.jpg" alt="Zavanda Homepage" width="560" height="368" /></p>
<p>Requirements &amp; Solution:</p>
<ul>
<li>Simple Public / Administration Web Interface</li>
<li>Online Payment Tracking (using Paypal)</li>
<li>Developer API</li>
<li>Pay-as-you-go business model</li>
<li>Public accessible (secure) customer portal</li>
<li>Email Notification System</li>
<li><a href="http://www.highrisehq.com" target="_blank">Highrise</a> CRM integration</li>
<li>Ticket Time Tracking</li>
</ul>
<div class="portfolio-thumb"><a href="/wp-content/uploads/2010/01/zavanda-account-settings.jpg" rel="lightbox[Zavanda Account Settings]"><img class="aligncenter size-thumbnail wp-image-94" title="Zavanda Account Settings" src="/wp-content/uploads/2010/01/zavanda-account-settings-150x150.jpg" alt="Zavanda Account Settings" width="150" height="150"  /></a></div>
<div class="portfolio-thumb"><a href="/wp-content/uploads/2010/01/zavanda-create-ticket.jpg"  rel="lightbox[Zavanda Create A Ticket]"><img class="aligncenter size-thumbnail wp-image-95" title="Zavanda Create A Ticket" src="/wp-content/uploads/2010/01/zavanda-create-ticket-150x150.jpg" alt="Zavanda Create A Ticket" width="150" height="150" /></a></div>
<div class="portfolio-thumb"><a href="/wp-content/uploads/2010/01/zavanda-customer.jpg"  rel="lightbox[Zavanda Customer Details]"><img class="aligncenter size-thumbnail wp-image-96" title="Zavanda Customer Details" src="/wp-content/uploads/2010/01/zavanda-customer-150x150.jpg" alt="Zavanda Customer Details" width="150" height="150" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://dizzytree.com/2010/01/portfolio-zavanda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
