<?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>Down Lifes Road... &#187; Casey</title>
	<atom:link href="http://www.downlifesroad.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.downlifesroad.com</link>
	<description></description>
	<lastBuildDate>Wed, 04 Aug 2010 22:37:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zend Framework Twitter and oAuth in 1.10.7</title>
		<link>http://www.downlifesroad.com/2010/08/04/zend-framework-twitter-and-oauth-in-1-10-7/</link>
		<comments>http://www.downlifesroad.com/2010/08/04/zend-framework-twitter-and-oauth-in-1-10-7/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 21:07:18 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=40</guid>
		<description><![CDATA[Today I wanted need to switch out some implementations I have in twitter. I was using HTTP Basic for authentication as were most. I went through the Zend Oauth docs, and combined with their examples and those of Pádraic Brady I got this working fine. I&#8217;m not going to give a step by step, as [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wanted need to switch out some implementations I have in twitter. I was using HTTP Basic for authentication as were most. I went through the Zend Oauth docs, and combined with their examples and those of <a href="http://blog.astrumfutura.com/archives/411-Writing-A-Simple-Twitter-Client-Using-the-PHP-Zend-Frameworks-OAuth-Library-Zend_Oauth.html">Pádraic Brady</a> I got this working fine.</p>
<p>I&#8217;m not going to give a step by step, as I&#8217;m assuming you&#8217;ve already read <a href="http://framework.zend.com/manual/en/zend.service.twitter.html">various</a> <a href="http://framework.zend.com/manual/en/zend.oauth.introduction.html">docs</a>.</p>
<p>I broke my files out like Pádraic, so if you&#8217;ve read his than you&#8217;ll understand mine.</p>
<p>First, my config file which is included within each subsequent file.</p>
<pre class="brush:php">
$config = array(
        'callbackUrl'    => 'http://www.example.com/callback.php',
        'siteUrl'        => 'http://twitter.com/oauth',
        'consumerKey'    => 'XXXXXXXXXXXXXXXXXXXXX',
        'consumerSecret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
);</pre>
<p>My index page is the starting point of the authentication process. Our persistent storage for this example is in session, though in production I&#8217;m using a database.</p>
<pre class="brush:php">
include_once './config.php';

if (!$_SESSION['TWITTER_REQUEST_TOKEN']) {
    // $config is from our include!
    $consumer = new Zend_Oauth_Consumer($config);

    // fetch a request token
    $token = $consumer->getRequestToken();

    // persist the token to storage
    $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);

    // redirect the user
    $consumer->redirect();
}
</pre>
<p>The callback url specified will now be triggered</p>
<pre class="brush:php">
include_once './config.php';

// Check if _GET is set and that the request token is being returned
if (!empty($_GET) &#038;&#038; isset($_SESSION['TWITTER_REQUEST_TOKEN'])) {

    $consumer = new Zend_Oauth_Consumer($config);
    $token = $consumer->getAccessToken($_GET, unserialize($_SESSION['TWITTER_REQUEST_TOKEN']));

    $_SESSION['TWITTER_ACCESS_TOKEN'] = serialize($token);

    // Now that we have an Access Token, we can discard the Request Token
    $_SESSION['TWITTER_REQUEST_TOKEN'] = null;
} else {
    // Mistaken request? Some malfeasant trying something?
    exit('Invalid callback request. Oops. Sorry.');
}

// Lets just pass on to a test posting page
redirect_url('post.php');
</pre>
<p>Finally, if all went to plan and the user authorized our application, we can pull in their access token and do as we need on their behalf.</p>
<pre class="brush:php">
include_once './config.php';

// Verify we're good to go
if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])) {

    // Unserialize and add the token to the config
    $token = unserialize($_SESSION['TWITTER_ACCESS_TOKEN']);
    $config['accessToken'] = $token;

    // Pass the config into Twitter, and act upon the users account
    $twitter = new Zend_Service_Twitter($config);

    $twitter->status->update('I am so posting from your account. Rock!');
}
</pre>
<p>That&#8217;s all really. I do wish the Zend Service Twitter docs would be updated to reflect some examples. I saw in SVN Pádraic has already changed some of the docs, they&#8217;ve just not been updated on site yet.</p>
<p>Thanks to the documentation authors and those I borrowed from to get my working example going and so I could more easily move forward with this project.</p>
<p>-Casey</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2010/08/04/zend-framework-twitter-and-oauth-in-1-10-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Soap Client timeout</title>
		<link>http://www.downlifesroad.com/2010/07/06/zend-soap-client-timeout/</link>
		<comments>http://www.downlifesroad.com/2010/07/06/zend-soap-client-timeout/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:47:54 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=32</guid>
		<description><![CDATA[I&#8217;m working with a web service that&#8217;s showing to be slow at times. The default timeout in PHP is 30 seconds currently, so waiting around for it to timeout kinda sucks. I decided to set the timeout to 10 seconds, to my surprise the timeout code is completely commented out in the class. However they [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working with a web service that&#8217;s showing to be slow at times. The default timeout in PHP is 30 seconds currently, so waiting around for it to timeout kinda sucks.</p>
<p>I decided to set the timeout to 10 seconds, to my surprise the timeout code is completely commented out in the class.</p>
<p>However they do provide a setStreamContext(), so I set http to timeout after 10 seconds like so:</p>
<pre class="brush:php">$context = stream_context_create(array('http' =&gt; array('timeout' =&gt; 10)));
$soapClient-&gt;setStreamContext($context);
</pre>
<p>When the service slowed down to 15 second wait times, it died out early like it should have. I&#8217;m catching the exception, which isn&#8217;t pretty. Wish I knew when it was timing out, so I could log that specific case.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2010/07/06/zend-soap-client-timeout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crazy economic times &#8211; Looking for a new job?</title>
		<link>http://www.downlifesroad.com/2010/06/10/crazy-economic-times-looking-for-a-new-job/</link>
		<comments>http://www.downlifesroad.com/2010/06/10/crazy-economic-times-looking-for-a-new-job/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 16:31:53 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[life]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=25</guid>
		<description><![CDATA[It&#8217;s true, times are bad. I saw a family down the road who had to &#8220;move&#8221; out of their home. In my area there was one major company for many years, my father in law worked there for 30 years, his friends did too, hell, most people I knew had some affiliation with that company. [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s true, times are bad. I saw a family down the road who had to &#8220;move&#8221; out of their home.</p>
<p>In my area there was one major company for many years, my father in law worked there for 30 years, his friends did too, hell, most people I knew had some affiliation with that company.</p>
<p>Then bam, they were told they were moving overseas and everyone would be losing their jobs.</p>
<p>I&#8217;ve been trying to help my father in law find a new job, we&#8217;ve been going through many sites etc. One last night was used, he found something he liked an put in a resume. Pretty nice. It&#8217;s a <a title="Job Search Engine" href="http://www.jobinventory.com" target="_blank">Job Search Engine</a> and it looks promising.</p>
<p>Goodluck to those out seeking, hopefully everything will work out well.</p>
<p>-Casey</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2010/06/10/crazy-economic-times-looking-for-a-new-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Form Element Radio and Default value</title>
		<link>http://www.downlifesroad.com/2009/10/27/zend-form-element-radio-and-default-value/</link>
		<comments>http://www.downlifesroad.com/2009/10/27/zend-form-element-radio-and-default-value/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:44:59 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=21</guid>
		<description><![CDATA[I setup a Zend Form object and needed radio buttons, but also needed a default value. Took me a few minutes to find, but here&#8217;s an example of use. /** * Setting some values for our radio buttons. */ $options = array( '1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3' ); [...]]]></description>
			<content:encoded><![CDATA[<p>I setup a Zend Form object and needed radio buttons, but also needed a default value. Took me a few minutes to find, but here&#8217;s an example of use.</p>
<pre lang="php">
/**
 * Setting some values for our radio buttons.
 */
$options = array(
    '1' => 'Option 1',
    '2' => 'Option 2',
    '3' => 'Option 3'
);

/**
 * The array('value' => 2) below sets our default value.
 */
$radio = new Zend_Form_Element_Radio('elementName', array('value' => '2'));
$radio->addMultiOptions($options);
$this->addElement($radio);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2009/10/27/zend-form-element-radio-and-default-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade Zend Framework in Zend Server CE</title>
		<link>http://www.downlifesroad.com/2009/08/22/upgrade-zend-framework-in-zend-server-ce/</link>
		<comments>http://www.downlifesroad.com/2009/08/22/upgrade-zend-framework-in-zend-server-ce/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 16:18:43 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[zend server ce]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=16</guid>
		<description><![CDATA[First off, this isn&#8217;t meant as a tutorial, but more of a general way of handling various libraries in this situation. We&#8217;ve recently started to use Zend Server CE on our development machines at work. With the release of Zend Framework 1.9, we wanted to upgrade but still maintain previous versions. When I download the [...]]]></description>
			<content:encoded><![CDATA[<p>First off, this isn&#8217;t meant as a tutorial, but more of a general way of handling various libraries in this situation.</p>
<p>We&#8217;ve recently started to use Zend Server CE on our development machines at work.</p>
<p>With the release of Zend Framework 1.9, we wanted to upgrade but still maintain previous versions.</p>
<p>When I download the framework, I prefer to use svn and grab the tag, in this case: http://framework.zend.com/svn/framework/standard/tags/release-1.9.0/</p>
<p>The structure I chose was:</p>
<p>/usr/local/zend/shared/ZendFrameworkSource/&lt;version&gt;</p>
<p>I then created a <a href="http://en.wikipedia.org/wiki/Symbolic_link" target="_blank">symbolic link</a> to the version I want and put that in my include_path.</p>
<p>Example: /usr/local/zend/shared/ZendFrameworkLibrary/ -&gt; /usr/local/zend/shared/ZendFrameworkSource/1.9.0/library/</p>
<p>Now with each upgrade, I only update the symbolic link and each application is switched to the new version.</p>
<p>Have a better way? Let me know, I&#8217;m always interested in learning.</p>
<p>-Casey</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2009/08/22/upgrade-zend-framework-in-zend-server-ce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Old code.</title>
		<link>http://www.downlifesroad.com/2008/09/18/old-code/</link>
		<comments>http://www.downlifesroad.com/2008/09/18/old-code/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 22:35:59 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=12</guid>
		<description><![CDATA[I love coming across old code *cough* garbage *cough* The purpose of this was to take a title, and create something url safe and in the fashion a client was wanting. The first function was old code, so don&#8217;t blame me. function cleanUrl($url) { $find = array('/--/', '/ - /','/ /', '/!/', '/"/', "/'/", '/--/'); [...]]]></description>
			<content:encoded><![CDATA[<p>I love coming across old code *cough* garbage *cough*</p>
<p>The purpose of this was to take a title, and create something url safe and in the fashion a client was wanting. The first function was old code, so don&#8217;t blame me.</p>
<pre lang="php">
function cleanUrl($url)
{
  $find =        array('/--/', '/ - /','/ /', '/!/', '/"/', "/'/", '/--/');
  $replace =    array('-', '-', '-', '', '', '', '-');

  $result = strtr($url, "`~@#$%^&#038;*()_=+|[]{};:,./<>?", "---------------------------");

  return strtolower(preg_replace($find, $replace, strip_tags(stripslashes(trim($result)))));
}
</pre>
<p>Isn&#8217;t it horrible?</p>
<p>I rewrote the function to&#8230;</p>
<pre lang="php">
function cleanUrl($url)
{
  $url = strtolower($url);

  $url = preg_replace("/[^a-z0-9\s+]/", '', $url);
  $url = preg_replace("/[\s]{1,}/", '-', $url);

  return $url;
}
</pre>
<p>That makes me happier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2008/09/18/old-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lazy day</title>
		<link>http://www.downlifesroad.com/2008/09/13/lazy-day/</link>
		<comments>http://www.downlifesroad.com/2008/09/13/lazy-day/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 17:30:02 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/?p=8</guid>
		<description><![CDATA[Today is rainy and full of nastiness. (Thanks Ike!) I should have gotten out to play disc golf while the weather was beautiful, I just didn&#8217;t feel too hot. Called my sister Meagan a few times, her voicemail is picking up so I&#8217;m yelling in a demonic sounding voice and hanging up. Hopefully it freaks [...]]]></description>
			<content:encoded><![CDATA[<p>Today is rainy and full of nastiness. (Thanks Ike!)</p>
<p>I should have gotten out to play disc golf while the weather was beautiful, I just didn&#8217;t feel too hot.</p>
<p>Called my sister Meagan a few times, her voicemail is picking up so I&#8217;m yelling in a demonic sounding voice and hanging up. Hopefully it freaks them out a bit. If not, well, no loss.</p>
<p>Work is going well, moving forward on some things and looking good.</p>
<p>Snapped a great picture of my brother in law, and his wifes brother being dorks. Put it up on my facebook in the mobile uploads.</p>
<p>This turned into more of a journal entry, rock on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2008/09/13/lazy-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ewerl Function</title>
		<link>http://www.downlifesroad.com/2008/06/29/ewerl-function/</link>
		<comments>http://www.downlifesroad.com/2008/06/29/ewerl-function/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 02:16:39 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/2008/06/29/ewerl-function/</guid>
		<description><![CDATA[Ewerl is a new URL rewritting site with cool features. Here&#8217;s a simple function to return the Ewerl url. It&#8217;s only being used for the main url, but could easily be adjusted to return an array. I just didn&#8217;t have a need for it in my case at this time. /** * Returns an Ewerl [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ewerl.com" title="Ewerl" target="_blank">Ewerl</a> is a new URL rewritting site with cool features.</p>
<p>Here&#8217;s a simple function to return the Ewerl url. It&#8217;s only being used for the main url, but could easily be adjusted to return an array. I just didn&#8217;t have a need for it in my case at this time.</p>
<pre lang="php">
/**
 * Returns an Ewerl url if available.
 * Otherwise the original that was passed in.
 * Returns false if..
 * 1. JSON extension isn't installed.
 * 2. No url was entered.
 * 3. No response from server.
 *
 * @todo Add URL validation.
 *
 * @param string $url
 * @return string URL, or false.
 * @author Casey Wilson <caseyw@downlifesroad.com>
 */
function getEwerl($url) {
	/**
	 * Verify JSON extension is loaded.
	 */
	if (!extension_loaded('JSON')) return false;

	/**
	 * Url wasn't passed
	 */
	if (!$url) return false;

	/**
	 * Assign / Prep vars.
	 */
	$postUrl = 'http://ewerl.com/api/v1/make/url=';
	$urlEncoded = base64_encode($url);

	$response = file_get_contents($postUrl . $urlEncoded);

	if (!$response) {
		return $url;
	}

	/**
	 * Should have returned a JSON object.
	 */
	$jsonObj = json_decode($response);

	/**
	 * If either Status not set, or status is false, return original url.
	 */
	if (!isset($jsonObj->status) || $jsonObj->status == 'FALSE') {
		return $url;
	}

	return $jsonObj->url_main;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2008/06/29/ewerl-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery</title>
		<link>http://www.downlifesroad.com/2008/06/29/jquery/</link>
		<comments>http://www.downlifesroad.com/2008/06/29/jquery/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 14:56:34 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/2008/06/29/jquery/</guid>
		<description><![CDATA[My expierence with jQuery thus far hasn&#8217;t been to bad. I&#8217;m starting to see the power and simplicity of it. I&#8217;ve never been a JS guy, never been in a position to really need to do much with it since I&#8217;ve basically always been a backend coder. I need to really jump in there, get [...]]]></description>
			<content:encoded><![CDATA[<p>My expierence with jQuery thus far hasn&#8217;t been to bad. I&#8217;m starting to see the power and simplicity of it.</p>
<p>I&#8217;ve never been a JS guy, never been in a position to really need to do much with it since I&#8217;ve basically always been a backend coder. I need to really jump in there, get a good feel for both JS and jQuery. So far though, I can say I&#8217;m really starting to like it, only been at it a few days thus far so we&#8217;ll see here soon what the final say is.</p>
<p>Thanks to good friends, and long late night chats with people smarter than I.</p>
<p>The open source community as a whole rocks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2008/06/29/jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Url to TinyUrl Function</title>
		<link>http://www.downlifesroad.com/2008/06/21/url-to-tinyurl-function/</link>
		<comments>http://www.downlifesroad.com/2008/06/21/url-to-tinyurl-function/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 03:29:19 +0000</pubDate>
		<dc:creator>Casey</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.downlifesroad.com/2008/06/21/url-to-tinyurl-function/</guid>
		<description><![CDATA[I needed to transform some long urls into tiny ones :p Figured I&#8217;d post something up here that may be useful to someone else. Code was updated. /** * Get TinyUrl for $url * * @param string $url Must be a valid url */ function getTinyUrl($url) { if (! $url) { return false; } if [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to transform some long urls into tiny ones :p</p>
<p>Figured I&#8217;d post something up here that may be useful to someone else.</p>
<p>Code was updated.</p>
<pre lang="php">
/**
 * Get TinyUrl for $url
 *
 * @param string $url Must be a valid url
 */
function getTinyUrl($url) {
	if (! $url) {
		return false;
	}

	if (strlen ( $url ) < 30) {
		return $url;
	}

	$response = file_get_contents ( 'http://tinyurl.com/api-create.php?url=' . $url );

	return ($response) ? $response : $url;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.downlifesroad.com/2008/06/21/url-to-tinyurl-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
