<?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>JustNI Blog - Programming and startup chit chat</title>
	<atom:link href="http://blog.justni.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justni.com</link>
	<description>Creating Change</description>
	<lastBuildDate>Thu, 11 Apr 2013 14:14:47 +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>Posting to linkedin from php and codeigniter</title>
		<link>http://blog.justni.com/posting-to-linkedin-from-php-and-codeigniter/</link>
		<comments>http://blog.justni.com/posting-to-linkedin-from-php-and-codeigniter/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 08:39:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=168</guid>
		<description><![CDATA[I recently got tasked with posting offline messages to twitter, i.e when a user completes an action on my application, there would be a message posted to linkedin.
I looked at the many oauth libraries about on the web for php and codeigniter and couldn&#8217;t find one that worked perfectly for my situation so i mashed [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got tasked with posting offline messages to twitter, i.e when a user completes an action on my application, there would be a message posted to linkedin.</p>
<p>I looked at the many oauth libraries about on the web for php and codeigniter and couldn&#8217;t find one that worked perfectly for my situation so i mashed a few together and ended up with this- and i learnt a few lessons on the way.</p>
<p>Where I got the php libraries that where built around the linkedin api, nothing was clean and coherent.. and simple  so I found a twitter library and modified it to my needs- both linkedin and twitter are built around OAUTH (so is facebook) and this made it super easy to change a few urls and directories and have a working library.</p>
<p>The source for my derived work came from this library listed here -<a href="https://www.packtpub.com/article/user-authentication-with-codeigniter-1.7-using-twitter-oauth"> https://www.packtpub.com/article/user-authentication-with-codeigniter-1.7-using-twitter-oauth</a> if you check my code you will see i edited slightly to change it for use with linkedin. If your using this library you will also need the PHP oauth Library which is listed here- <a href="http://oauth.googlecode.com/svn/code/php/">http://oauth.googlecode.com/svn/code/php/</a></p>
<p>The library- save this as linked.php in your application/libraries folder- also save your &#8220;OAuth.php&#8221; in there as well</p>
<p><H3>The llibrary</H3></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OAuth.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> linkedin
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$consumer</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$token</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$method</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$http_status</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$last_api_call</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$callback</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> linkedin<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">method</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OAuthSignatureMethod_HMAC_SHA1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OAuthConsumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'consumer_key'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'consumer_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callback</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'callback_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//print_r($data);</span>
&nbsp;
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'callback_url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OAuthConsumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">function</span> debug_info<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Last API Call: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">last_api_call</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Response Code: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">http_status</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">function</span> get_request_token<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	 <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'scope'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'r_basicprofile,r_network,rw_nus'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> OAuthRequest<span style="color: #339933;">::</span><span style="color: #004000;">from_consumer_and_token</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span><span style="color: #339933;">,</span>
		 <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'GET'</span><span style="color: #339933;">,</span>
		  <span style="color: #0000ff;">&quot;https://api.linkedin.com/uas/oauth/requestToken&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_parameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;oauth_callback&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callback</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sign_request</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">method</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">http</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to_url</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OAuthConsumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">callback</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$token</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> get_access_token<span style="color: #009900;">&#40;</span><span style="color: #000088;">$oauth_verifier</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> OAuthRequest<span style="color: #339933;">::</span><span style="color: #004000;">from_consumer_and_token</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'GET'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;https://api.linkedin.com/uas/oauth/accessToken&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_parameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;oauth_verifier&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$oauth_verifier</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sign_request</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">method</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">http</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to_url</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$request</span> <span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">,</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//echo $oauth_verifier;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OAuthConsumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$token</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	 <span style="color: #000000; font-weight: bold;">function</span> parse_request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span>
	 <span style="color: #009900;">&#123;</span>
		 <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;=&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;=&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		 <span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'2'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'2'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'3'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'3'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$token</span><span style="color: #339933;">;</span>
	 <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> parse_access<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$pair</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'='</span><span style="color: #339933;">,</span> <span style="color: #000088;">$param</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pair</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$r</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">urldecode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pair</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urldecode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pair</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$r</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> get_authorize_URL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;https://api.linkedin.com/uas/oauth/authorize?oauth_token=&quot;</span> <span style="color: #339933;">.</span>
		  <span style="color: #000088;">$token</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> http<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post_data</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CURL_CA_BUNDLE_PATH&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_CAINFO<span style="color: #339933;">,</span> CURL_CA_BUNDLE_PATH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_TIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_SSL_VERIFYPEER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post_data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">http_status</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_getinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLINFO_HTTP_CODE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">last_api_call</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$response</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #000000; font-weight: bold;">function</span> share<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">,</span> <span style="color: #000088;">$title</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imageUrl</span><span style="color: #339933;">,</span> <span style="color: #000088;">$description</span><span style="color: #339933;">,</span> <span style="color: #000088;">$access_token</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$shareUrl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://api.linkedin.com/v1/people/~/shares&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;share&gt;
		      &lt;comment&gt;<span style="color: #006699; font-weight: bold;">$comment</span>&lt;/comment&gt;
		      &lt;content&gt;
		         &lt;title&gt;<span style="color: #006699; font-weight: bold;">$title</span>&lt;/title&gt;
		         &lt;submitted-url&gt;<span style="color: #006699; font-weight: bold;">$url</span>&lt;/submitted-url&gt;
		         &lt;submitted-image-url&gt;<span style="color: #006699; font-weight: bold;">$imageUrl</span>&lt;/submitted-image-url&gt;
		         &lt;description&gt;<span style="color: #006699; font-weight: bold;">$description</span>&lt;/description&gt;
		      &lt;/content&gt;
		      &lt;visibility&gt;
		         <code>anyone</code>
		      &lt;/visibility&gt;
		    &lt;/share&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> OAuthRequest<span style="color: #339933;">::</span><span style="color: #004000;">from_consumer_and_token</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span><span style="color: #339933;">,</span> <span style="color: #000088;">$access_token</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$shareUrl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sign_request</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">method</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">consumer</span><span style="color: #339933;">,</span> <span style="color: #000088;">$access_token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$auth_header</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to_header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://api.linkedin.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">httpRequest</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$shareUrl</span><span style="color: #339933;">,</span> <span style="color: #000088;">$auth_header</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$response</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> httpRequest<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$auth_header</span><span style="color: #339933;">,</span> <span style="color: #000088;">$method</span><span style="color: #339933;">,</span> <span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//echo $url. &quot; &quot; .$method. &quot; &quot; .$body;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//echo $auth_header;</span>
&nbsp;
		<span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth_header</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Set the headers.</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//echo $auth_header;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_CUSTOMREQUEST<span style="color: #339933;">,</span> <span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth_header</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Content-Type: text/xml;charset=utf-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #990000;">curl_getinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLINFO_HTTP_CODE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//if ($this-&gt;debug) {</span>
			<span style="color: #666666; font-style: italic;">//echo &quot;bla&quot;;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//}</span>
&nbsp;
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>I have commented the code more so than giving a run through of how it works.</p>
<p><H3>The codeigniter stuff <img src='http://blog.justni.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </H3></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #000000; font-weight: bold;">extends</span> controller <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> user<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #990000;">parse_str</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strrchr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'consumer_key'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'consumer_secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'callback_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;yourcallback&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> linkedin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linkedin'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkedin</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_request_token</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_request_token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_request_token_secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>   <span style="color: #000088;">$token</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$request_link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkedin</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_authorize_URL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$request_link</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request_link</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> linkedin_submit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_request_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_request_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">//laod the library with the variables defined in the constructor</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linkedin'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//echo $_REQUEST['oauth_verifier'];</span>
&nbsp;
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_verifier'</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span>  <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_verifier'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/* Request access tokens from linkedin */</span>
		<span style="color: #000088;">$tokens</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkedin</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_access_token</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_verifier'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">/*Save the access tokens.*/</span>
		<span style="color: #666666; font-style: italic;">/*Normally these would be saved in a database for future use. */</span>
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_access_token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tokens</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_access_token_secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tokens</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_token_secret'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//store your user info</span>
		<span style="color: #666666; font-style: italic;">//if your going to store the tokens you will need to serialise in and out of the db</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// you will need to write your own models- simple storage- serialization done here in the controller</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'muser'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$data_id</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linked_in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkedin</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$user_id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'oauth_secret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'oauth_verifier'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//i used this to store the link_in tokens in the db</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">muser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store_id</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//error</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> linkedin_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">//this is the get from db</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">//you will have to make your own models</span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
&nbsp;
		<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">muser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_by_id</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$linked_in</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'linked_in'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">//setup the post info</span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
		<span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;message&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;story title&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$targetUrl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://link&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$imgUrl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;image title&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">//load the library for linkedin with the variables defined in the constructor </span>
		<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'linkedin'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #000088;">$apiCallStatus</span>    <span style="color: #339933;">=</span>   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">linkedin</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">share</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">,</span> <span style="color: #000088;">$title</span><span style="color: #339933;">,</span> <span style="color: #000088;">$targetUrl</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imgUrl</span><span style="color: #339933;">,</span><span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$linked_in</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/posting-to-linkedin-from-php-and-codeigniter/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Quick web application development with fuelphp tutorial</title>
		<link>http://blog.justni.com/quick-web-application-development-with-fuelphp-tutorial/</link>
		<comments>http://blog.justni.com/quick-web-application-development-with-fuelphp-tutorial/#comments</comments>
		<pubDate>Wed, 25 May 2011 13:24:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[fuelphp]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=158</guid>
		<description><![CDATA[Project description
I have been assigned the task of building a data collection tool which will be used on a website which has been built to target certain keyword terms- you can view the website and the finished product at Debt Solutions Ireland
Website description
Debt problems can lead to many sleepless nights and a very stressful living. [...]]]></description>
			<content:encoded><![CDATA[<h3>Project description</h3>
<p>I have been assigned the task of building a data collection tool which will be used on a website which has been built to target certain keyword terms- you can view the website and the finished product at <a href="http://debtsolutionsireland.com/">Debt Solutions Ireland</a></p>
<h3>Website description</h3>
<p>Debt problems can lead to many sleepless nights and a very stressful living. There are many services out there that can help consolidate debts and reduce payments.</p>
<h3>The problem</h3>
<p>We need a tool that we can use to collect leads (user information)</p>
<h3>What you need</h3>
<ul>
<li>PHP 	5.3/mysql/apache- I use xampplite which comes with php 5.3.5 at time 	of writing and can be downloaded here- 	<a href="http://www.apachefriends.org/en/xampp-windows.html">http://www.apachefriends.org/en/xampp-windows.html</a></li>
<li>An editor- I edit 	on windows and therefore use notepad++, it rocks, its highly 	configurable and does the job- get it here 	<a href="http://notepad-plus-plus.org/">http://notepad-plus-plus.org/</a></li>
<li>Something to unzip 	your download winrar I use- get it here 	<a href="http://www.rarlab.com/download.htm">http://www.rarlab.com/download.htm</a></li>
</ul>
<h3>Let&#8217;s get started</h3>
<p>1 . First step is to visit <a href="http://fuelphp.com/">http://fuelphp.com/</a></p>
<p><img src="http://blog.justni.com/imgs/fuelphp/1.png" border="0"/></p>
<p>2. Download and unzip – I used winrar to unzip into a new folder in my  xampplite htdocs folder- lets call it debt3</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/2.png" border="0"/></p>
<p>3. Time to configure 	some of the files. All the files for your application will be 	contained in the fuel/app/ folder. We need to set ourselves up a 	database to start with, if oyur using xampplite like I am just start 	xampp up (theres a shortcut in the start menu) and load up 	<a href="http://localhost/phpmyadmin">http://localhost/phpmyadmin</a> into your browser. From here there will be an option to create a new 	database, I called my fuel_dev to match up <img src='http://blog.justni.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You can now go to the 	database config file which is locate din the fuel/app/config folder 	add in your details</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/3.png" border="0"/></p>
<p>4.Next job is to do 	some configuration in the main config file, on line 22 we&#8217;ll remove 	the index.php so we get nice clean looking URL&#8217;s. Then we will add 	in the two packages we are going to use into our packages array- 	this is located on line 135 &#8216;orm&#8217;,'auth&#8217;<br/><br />
<img src="http://blog.justni.com/imgs/fuelphp/4.png" border="0"/></p>
<p>5. Thats the 	configuration done now, next job is to move the assets and configure 	the paths. Since I will be uploading only the application files to 	my webserver when I&#8217;m deploying I&#8217;m going to move the contents of 	the /public folder into the root directory- This will allow me to 	open my browser and  pump in http://localhost/debt3 and see my 	application. (when we upload i&#8217;ll remove oil.php so it can&#8217;t be run 	on the server). The folder should now look like this</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/5.png" border="0"/></p>
<p>6. Any images, 	javascript files or css files will now go in the /assets folder, 	were we can reference them in our code using one of the classes. 	Next job is to edit the paths in the index.php so it matches up with 	our new directory structure. On line 14 I have removed ../ from the 	directory structure and the following two lines as well.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$app_path</span>		<span style="color: #339933;">=</span> <span style="color: #0000ff;">'../fuel/app/'</span><span style="color: #339933;">;</span></pre></div></div>

<p> becomes</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$app_path</span>		<span style="color: #339933;">=</span> <span style="color: #0000ff;">'fuel/app/'</span><span style="color: #339933;">;</span></pre></div></div>

<p>7.You can see what 	all three of my paths now look like-<br />
<img src="http://blog.justni.com/imgs/fuelphp/6.png" border="0"/></p>
<p>8. Once you have 	swapped the paths out- open your browser and load your install (mine 	is located at <a href="http://localhost/debt3/">http://localhost/debt3/</a> )- this is what mine looks like <img src='http://blog.justni.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://blog.justni.com/imgs/fuelphp/7.png" border="0"/></p>
<p>9. Locate your 	fuelphp folder and open a command prompt folder into the root 	directory of the unzipped files now located in your htdocs folder- 	mine is – C:\xampplite\htdocs\debt3- to get to the directory open 	a dos prompt by typing command into the run tab on the start menu then typing cd c:\folder</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/8.png" border="0"/></p>
<p>10. From here, we are going to start to code! We are going to 	start by scaffolding our lead administration interface, we are going 	to have 3 controllers and 3 tables in our database. The 3 	controllers are leads, users and the default welcome controller. The 	three tables are going to be- leads, migrations and users.<br />
11. The process to 	create our application will be to create all the appropriate data 	capture mechanisms then lock down the correct controllers with the 	authentication library<br />
12. To scaffold our 	leads controllers we want to store the following information</li>
<table border="1" cellspacing="0" cellpadding="4" width="100%" bordercolor="#000000">
<colgroup>
<col width="128*"></col>
<col width="128*"></col>
</colgroup>
<tbody>
<tr valign="TOP">
<td width="50%">Total_debt</td>
<td width="50%">We want to be able to sort the leads that we 				generate</td>
</tr>
<tr valign="TOP">
<td width="50%">Creditors</td>
<td width="50%">We want to know if a lead is suitable by the 				amount of creditors they have</td>
</tr>
<tr valign="TOP">
<td width="50%">Employment</td>
<td width="50%">We would like to know their employment status</td>
</tr>
<tr valign="TOP">
<td width="50%">first_name</td>
<td width="50%">Obviously we need to know their name</td>
</tr>
<tr valign="TOP">
<td width="50%">last_name</td>
<td width="50%">As above</td>
</tr>
<tr valign="TOP">
<td width="50%">Email</td>
<td width="50%">We need details in case we can&#8217;t get in 				contact with them over the phone</td>
</tr>
<tr valign="TOP">
<td width="50%">Suitable</td>
<td width="50%">A suitable time to contact the lead</td>
</tr>
<tr valign="TOP">
<td width="50%">Dated</td>
<td width="50%">A date of when they submitted the request for 				information form</td>
</tr>
<tr valign="TOP">
<td width="50%">Phone</td>
<td width="50%">A phone number to contact them with</td>
</tr>
</tbody>
</table>
<p><img src="http://blog.justni.com/imgs/fuelphp/9.png" border="0"/></p>
<p>13. Once we have this done we can now run the migration- you can open your migrations folder located in /fuel/app/migrations and it should be called 001_create_leads.php 001 represents it being our first migration</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/10.png" border="0"/></p>
<p>This is what my file looks like. Now lets run the migration by typing in php oil refine migrate<br />
into our dos window. If you get an error you probably do not have your database configured correctly.</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/11.png" border="0"/></p>
<p>We now should have a working application, fire up your web browser again and navigate over to the url of your app- mine is <a href="http://localhost/debt3/">http://localhost/debt3/</a> (if you get an class not found error you probably never loaded the 	orm library in step 4, go back and revise). If everything worked 	correctly then you should have a nice screen like this one below- 	which lets you add/delete and update current leads</p>
<p>Go ahead and add a new lead to test it out, you deserve this little reward.</p>
<p>14.Next step is to setup our welcome controller to post the leads from the home page, I have designed my home page and have already built the form- the form is basically the following elements</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;form action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span>Uri<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome/submit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;lead_form&quot; accept-charset=&quot;utf-8&quot; method=&quot;post&quot; onsubmit=&quot;return validateForm()&quot; &gt;
&lt;table align=&quot;center&quot; width=&quot;500&quot; cellpadding=&quot;5&quot; s&gt;
	&lt;tr&gt;
		&lt;td&gt;Total Unsecured Debt&lt;/td&gt;
		&lt;td&gt;
			&lt;select name=&quot;total_debt&quot; style=&quot;width:160px&quot;&gt;
			&lt;option value=&quot;&quot;&gt;Please Select&lt;/option&gt;
			  &lt;option value=&quot;under 2k&quot;&gt;under €2000&lt;/option&gt;
			  &lt;option value=&quot;2k-5k&quot;&gt;€2000 -&gt; €5000&lt;/option&gt;
			  &lt;option value=&quot;5k-15k&quot;&gt;€5000-€15000&lt;/option&gt;
			  &lt;option value=&quot;15k+&quot;&gt;€15000+&lt;/option&gt;
			&lt;/select&gt;
&nbsp;
		&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;Creditors&lt;/td&gt;
		&lt;td&gt;&lt;select name=&quot;creditors&quot; style=&quot;width:160px&quot;&gt;
			&lt;option value=&quot;&quot;&gt;Please Select&lt;/option&gt;
			  &lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;
			  &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;
			  &lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;
			  &lt;option value=&quot;5+&quot;&gt;5&lt;/option&gt;
			&lt;/select&gt;
		&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;Employment Status&lt;/td&gt;
		&lt;td&gt;&lt;select name=&quot;employment&quot; style=&quot;width:160px&quot;&gt;
			 &lt;option value=&quot;&quot;&gt;Please Select&lt;/option&gt;
			  &lt;option value=&quot;Employed Fulltime&quot;&gt;Employed Fulltime&lt;/option&gt;
			  &lt;option value=&quot;Employed Parttime&quot;&gt;Employed Part Time&lt;/option&gt;
			  &lt;option value=&quot;Self Employed&quot;&gt;Self Employed&lt;/option&gt;
			  &lt;option value=&quot;Unemployed&quot;&gt;Unemployed&lt;/option&gt;
			  &lt;option value=&quot;Retired&quot;&gt;Retired&lt;/option&gt;
			  &lt;option value=&quot;Student&quot;&gt;Student&lt;/option&gt;
&nbsp;
			&lt;/select&gt;
&nbsp;
		&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;First Name&lt;/td&gt;
		&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;first_name&quot;&gt;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;Last Name&lt;/td&gt;
		&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;last_name&quot;&gt;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;Email&lt;/td&gt;
		&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;email&quot;&gt;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;Contact Number&lt;/td&gt;
		&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;phone&quot;&gt;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;Suitable time to call&lt;/td&gt;
		&lt;td&gt;
			&lt;select name=&quot;suitable&quot; style=&quot;width:160px&quot;&gt;
				&lt;option value=&quot;&quot;&gt;Please Select&lt;/option&gt;
				&lt;option value=&quot;Now&quot;&gt;Call Now&lt;/option&gt;
				&lt;option value=&quot;9am-12pm&lt;&quot;&gt;9am-12pm&lt;/option&gt;
				&lt;option value=&quot;12pm-2pm&quot;&gt;12pm-2pm&lt;/option&gt;
				&lt;option value=&quot;2pm-6pm&quot;&gt;2pm-6pm&lt;/option&gt;
				&lt;option value=&quot;6pm-9pm&quot;&gt;6pm-9pm&lt;/option&gt;
			&lt;/select&gt;
		&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;/td&gt;
		&lt;td&gt;&lt;INPUT TYPE=&quot;image&quot; SRC=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span> Asset<span style="color: #339933;">::</span><span style="color: #004000;">find_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'button_2.png'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;/&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;</pre></div></div>

<p>I have used limited fuelphp classes as I usually design the forms out html first and then move into programming them. I used the Asset::find_file(&#8216;button_2.png&#8217;,'img&#8217;) to locate the submit button in the assets/img folder  I also used the &lt;?=Uri::create(&#8216;welcome/submit&#8217;);?&gt; to create the location for where the form will be submitted. Also I used javascript to do the validation of the form on the client side rather than the server side.</p>
<p>This is what the controller looks like- firstly the index function to load the home page</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome/index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A very simple function is all thats needed- our index html page is the file named index.php and located in the fuel\app\views\welcome folder- just replace the index.php file thats there- our form is now submitting to welcome/submit which corresponds to action_submit function in our welcome controller, listed below</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_submit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$val</span> <span style="color: #339933;">=</span> Validation<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'first_name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'First Name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_rule</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'required'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Input<span style="color: #339933;">::</span><span style="color: #004000;">method</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'POST'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$lead</span> <span style="color: #339933;">=</span> Model_Lead<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'total_debt'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'total_debt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'creditors'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'creditors'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'employment'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'employment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'first_name'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'first_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'last_name'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'last_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'phone'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'phone'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'email'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'suitable'</span> <span style="color: #339933;">=&gt;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'suitable'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'dated'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'y-m-d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>	
			<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lead</span> and <span style="color: #000088;">$lead</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//Session::set_flash('notice', 'Added lead #' . $lead-&gt;id . '.');</span>
&nbsp;
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome/success'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				Session<span style="color: #339933;">::</span><span style="color: #004000;">set_flash</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'notice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Could not save lead.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				Response<span style="color: #339933;">::</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Leads&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">body</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'leads/create'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Just to explain some of the code, firstly we are testing to make sure the information was posted and it was someone just “getting the page- this could fill our database with dodgy 0 value inputs since we are doing the validation on the client side.  I have included one validation rule just to make sure nothing empty is being post on the first_name.</p>
<p>Once we have our array of input items- made out, its easy enough just to create a new lead object with the model and then lead-&gt;save() saves it- without even the need to go and write a function in our model to this.</p>
<p>If you now submit the form you should see a record appear in the database- check out the leads scaffold. You may need to add in the success view.</p>
<p>Once we have this tested and working, we are now going to lock down the leads controller so that only authorised users can view it</p>
<p>15. Create the user 	controller- Next thing to do is to go back to our command prompt and 	use oil to generate our controllers- type in the following command 	“php oil g controller users login logout” and this will generate 	our users controller with login and logout functions and views, 	although we will only be using the login view</p>
<p>16. Load up your 	controller and we are going to add to our controller functions- this 	what it currently looks like</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Controller_Users <span style="color: #000000; font-weight: bold;">extends</span> Controller_Template <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_login<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Users &amp;raquo; Login'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users/login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_logout<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Users &amp;raquo; Logout'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users/logout'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and now we are going to replace the action_login and action_logout with our own  code</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_login<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>Auth<span style="color: #339933;">::</span><span style="color: #004000;">check</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            Response<span style="color: #339933;">::</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'leads'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// user already logged in</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$val</span> <span style="color: #339933;">=</span> Validation<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_field</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Your username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required|min_length[3]|max_length[20]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_field</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Your password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required|min_length[3]|max_length[20]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$auth</span> <span style="color: #339933;">=</span> Auth<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validated</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validated</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                Session<span style="color: #339933;">::</span><span style="color: #004000;">set_flash</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'notice'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'FLASH: logged in'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Response<span style="color: #339933;">::</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'leads'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">else</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validated</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'errors'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Wrong username/password. Try again'</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validated</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'errors'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Wrong username/password combo. Try again'</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">else</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'errors'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Login'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'errors'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span> <span style="color: #339933;">=</span> View<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users/login'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_logout<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        Auth<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Response<span style="color: #339933;">::</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/users/login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the login function you can see that we are checking against whether the user is already holding a session- if they are just redirect them to the leads controller, remember we have already auto loaded the auth library.</p>
<p>The next part is the validation of our login fields, which is pretty straightforward. We then call  if($auth-&gt;login($val-&gt;validated(&#8216;username&#8217;), $val-&gt;validated(&#8216;password&#8217;))) to check the login, if its successful we then redirect the user to the leads controller, calling this function starts a session for the user. The rest of the controller is simply to validate the user information, load the login form and deal with any errors-</p>
<p>Our login form is pretty simple, we replace our login.php view with this code-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;h2&gt;Login&lt;/h2&gt;
&lt;p&gt;Login to your account using your username and password.&lt;/p&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$errors</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Form<span style="color: #339933;">::</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users/login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;div class=&quot;input text required&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Form<span style="color: #339933;">::</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Form<span style="color: #339933;">::</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$username</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'size'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&nbsp;
&lt;div class=&quot;input password required&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Form<span style="color: #339933;">::</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Form<span style="color: #339933;">::</span><span style="color: #004000;">password</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'size'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&nbsp;
&lt;div class=&quot;input submit&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Form<span style="color: #339933;">::</span><span style="color: #004000;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'login'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;</pre></div></div>

<p>This is using some of the fuelphp form class. This is how it looks in the browser</p>
<p><img src="http://blog.justni.com/imgs/fuelphp/13.png" border="0"/></p>
<p>In order to use this we must create a user account.</p>
<p>Go ahead and generate a migration by typing this into the command prompt again</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">php oil g migration create_users username<span style="color: #339933;">:</span>varchar<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#93;</span> password<span style="color: #339933;">:</span>varchar<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#93;</span> email<span style="color: #339933;">:</span>varchar<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">70</span><span style="color: #009900;">&#93;</span> profile_fields<span style="color: #339933;">:</span>text group<span style="color: #339933;">:</span>int<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">11</span><span style="color: #009900;">&#93;</span> last_login<span style="color: #339933;">:</span>int<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#93;</span> login_hash<span style="color: #339933;">:</span>varchar<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#93;</span></pre></div></div>

<p>and dont forget to run the migration once its created-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">php oil refine migrate</pre></div></div>

<p>One bit of configuration is required, we need to change the table name from simpleusers to users in fuel\packages\auth\config\simpleauth.php on line 24 it says</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'table_name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'simpleusers'</span><span style="color: #339933;">,</span></pre></div></div>

<p>change this to</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'table_name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'users'</span><span style="color: #339933;">,</span></pre></div></div>

<p>We now need to create our admin account, we are going to do this manually since there will be only one login, I&#8217;m going to create a temporary function which I will delete after I run it from the browser.</p>
<p>The function looks like this</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> action_create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$create_user</span> <span style="color: #339933;">=</span> Auth<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_user</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'chris@justni.com'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'100'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$create_user</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;User created&quot;</span><span style="color: #339933;">;</span>			
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;not created&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I just ran it there- of course you going to change the email address and password to match your own, but when your run it, it should say “User created” (you may get and error from the template but don&#8217;t worry about that) Now go back and remove the function as this application is only going to be used by the on person there is no need for the signup forms.</p>
<p>Next we are going to add some code to the before function in the leads controller. After you declare the class and before the rest of your functions add in the following function</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> before<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		parent<span style="color: #339933;">::</span><span style="color: #004000;">before</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> Auth<span style="color: #339933;">::</span><span style="color: #004000;">check</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            Response<span style="color: #339933;">::</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/users/login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This will check if the person is logged in and if not- redirect to the login page. And we&#8217;re done- you can see the site I built this for live now at <a href="http://debtsolutionsireland.com/">Debt Solutions Ireland</a></p>
<p>Summary</p>
<p>To finish with, I made some pointers on why to use fuelphp and why not-</p>
<p>Why not to use fuelphp</p>
<ul>
<li>API changed in 2 	months since I started using it, its not dramatic but its annoying</li>
<li>There is a few 	errors I came across while developing and some simple features are 	just not there</li>
<li>The documentation 	is nowhere near complete never mind at the level of codeigniter. 	There are parts of the documentation with just the headers</li>
<li>I was looking for 	a low cost web hosting solution that supported the features of php 	5.3 in Ireland, I wasn&#8217;t going to pay more than €5 or about $8 and 	I couldn&#8217;t find anyone, everyone kept trying to flog me dearer 	services or up sell vps which I didnt really want. I just wanted a 	cheap host with its services in Ireland, I couldn&#8217;t find anyone.</li>
<li>Magic migrations 	at the time of writing didn&#8217;t work completely</li>
</ul>
<p>Why to use fuelphp</p>
<ul>
<li>It has everything 	that you need out of the box, Auth/ACL and ORM- these items are what 	I miss the most from codeigniter</li>
<li>PHP 5.3, it uses 	namespaces and anonymous functions which will come into great use as 	more php coders get to grips with them.</li>
<li>It still has small 	footprint which is always a winner, some frameworks come out with 	little features and lots of code that doesnt do much, which makes it 	hard to learn, fuelphp is lightweight and feature rich- win/win in 	my books</li>
</ul>
<p>But, if FuelPHP was developed and commented thoroughly over the next 6-12 months I could be a great piece of kit, its already quite clean.</p>
<p><P><i><br />
Thanks to <a href="http://twitter.com/#!/Bravosms44">bravosms</a> in the comments for pointing out a typo<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/quick-web-application-development-with-fuelphp-tutorial/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>facebook marketing strategy to increase business page fans/likes</title>
		<link>http://blog.justni.com/facebook-marketing-strategy-to-increase-business-page-fans-likes/</link>
		<comments>http://blog.justni.com/facebook-marketing-strategy-to-increase-business-page-fans-likes/#comments</comments>
		<pubDate>Mon, 16 May 2011 12:30:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=151</guid>
		<description><![CDATA[ Introduction- this is for both consumer and business brands/pages
I was recently requested to quote for a project for a potential client who had a major brand on their books and they wanted a flash game developed in a very short time. Not only did they have an unrealistic time frame to have the game [...]]]></description>
			<content:encoded><![CDATA[<p><strong> Introduction- this is for both consumer and business brands/pages</strong></p>
<p>I was recently requested to quote for a project for a potential client who had a major brand on their books and they wanted a flash game developed in a very short time. Not only did they have an unrealistic time frame to have the game developed (a week) but they had no experience with facebook games and to top it of they didn&#8217;t even have an idea of what game they wanted.<br />
I suggested a cheaper solution (which I am going to detail below) that developing a game but they didn&#8217;t want to listen, therefore I quote an expensive price, if they wanted me to develop anything for them, they were going to have to pay for the headaches as well as my time..</p>
<p><strong>What did I suggest ? -&gt; “The gated competition”</strong></p>
<p>The gated competition, bends facebook&#8217;s terms of service but is very much a common practice now on facebook.</p>
<p>The gated competition is where a user has to “like” (pass through the gate) in order to take part in a competition. Once the user has liked the page, they are then presented the next stage, which is usually to enter their details to be entered into a draw or presented with a download link to download the “prize”. You can see a page I made for a client-</p>
<p><a href="http://www.facebook.com/newyorkcolor?sk=app_220712267941812"><img class="alignnone size-full wp-image-154" title="gated" src="http://blog.justni.com/wp-content/uploads/2011/05/gated.png" alt="" width="600" height="450" /></a></p>
<p><strong>So how do I win friends and influence people.. via facebook for my page</strong></p>
<p>Firstly- this isn&#8217;t a “free” solution- you need to spend time/money advertising your page to seed the campaign. The value in this  strategy is- that I can not find any strategy which returns the most return on investment which can scale in terms of developping new likes/leads on facebook</p>
<p><strong>There are three elements that make up this process-</strong></p>
<ol>
<li>The page</li>
<li>The prize</li>
<li>The advertising</li>
</ol>
<p>Without all three of these elements your campaign will not work fully</p>
<p><strong>The page-</strong></p>
<ul>
<li>The tab must be set as your default landing tab when someone visits your facebook page</li>
<li>The tab must be gated- the user can only interact with the tab if they have “liked” the page</li>
<li>The unlike tab must inform the user why they should like the page- your sales text</li>
<li>The tab must perform relevant task- allow data collection or generate download link</li>
<li>Once user has completed the task of the tab, they a presented to post to their wall that they have participated.</li>
<li>A privacy policy should be used to tell users why your collecting their data.</li>
</ul>
<p><strong>The prize</strong></p>
<ul>
<li>Give to receive. The prize is the incentive of why someone should come and like your page and enter for a chance to win the item.</li>
<li>Pick a prize that matches what the target demographic of your product or service that your potential customer. would be interested in. The person who contacted me to in enquire about developing game had very specific demographic information- 18-24 years old and mainly male, I suggested a gaming console with the latest guitar hero, plus a hamper of the product they where advertising.</li>
<li>If your a business to business page- give away a service or a product that matches what your business offers-</li>
</ul>
<p><strong>The advertising</strong></p>
<p>Without advertising the strategy doesn&#8217;t work to its full potential- if you have a few thousand likes already it may increase your likes by 0%-10%-20% over a monthly time frame but with advertising it can see even greater returns. Advertise the competition and the prize!</p>
<p><strong>Where to advertise </strong></p>
<ul>
<li>Facebook adverts allow you to advertise by demographic information and interests- this can be more advantageous when advertising consumer products</li>
<li>Google adwords can be used t target users with very specific key terms which can be more advantageous for companies advertising business to business products/services</li>
<li>Offline- if your business has premises- having the facebook icon dotted about the place with the URL can help- include your facebook URL in all print – on the back of business cards right through to product packaging.</li>
</ul>
<p><strong> The why</strong></p>
<ul>
<li>You can collect email addresses- you may not be able to get users to buy on facebook but people still buy from upselling in emails- groupon has seen their business explode with daily emails</li>
<li>You can collect likes within a targeted demographic/interest</li>
<li>You get most return on your investment. Instead of just advertising a facebook page- you can now collect email addresses and also encourage users to share content to their wall by making it the “next step” in the competition process</li>
<li>Once you have people like your page, you can create shareable branded content</li>
</ul>
<p><strong>The formula</strong></p>
<p>If you are not receiving enough likes from this strategy here are two points to consider<br />
Your advertising spend is not high enough, increase your advertising spend and you will see increased date collected<br />
If this didn&#8217;t work, maybe the prize was not a big enough fruit. Try the competition again with a larger prize.</p>
<p><strong>The trial-</strong></p>
<p>If you want to see how It looks-  check out <a href="http://www.facebook.com/newyorkcolor?sk=app_220712267941812">http://www.facebook.com/newyorkcolor</a> which now use the competition software</p>
<p><strong>The software</strong></p>
<p>If you fancy using this strategy that has seen great returns – here&#8217;s what the software does</p>
<ul>
<li>Checks if the user has liked the page or not</li>
<li>Validates and collects the data from the facebook tabs</li>
<li>Has a separate admin to view the collected data.</li>
<li>Separate Admin allows the export as csv to export data to an email marketing solution</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/facebook-marketing-strategy-to-increase-business-page-fans-likes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Checking in to facebook using the graph api and php</title>
		<link>http://blog.justni.com/checking-in-to-facebook-using-the-graph-api-and-php/</link>
		<comments>http://blog.justni.com/checking-in-to-facebook-using-the-graph-api-and-php/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 11:28:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[facebook checkins]]></category>
		<category><![CDATA[graph api]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=138</guid>
		<description><![CDATA[When a client contacted me last week to implement facebook checkins into an existing application i had to go searching for information. The only information i could get was from the API, there was no real tutorial out there explaining each step of the process- hopefully I address this issue.
firstly we need the user to [...]]]></description>
			<content:encoded><![CDATA[<p>When a client contacted me last week to implement facebook checkins into an existing application i had to go searching for information. The only information i could get was from the API, there was no real tutorial out there explaining each step of the process- hopefully I address this issue.</p>
<p>firstly we need the user to accept the application- we do this by bouncing them off to facebook &#8211; you need to include the facebook php library &#8211; <a href="https://github.com/facebook/php-sdk/">you can find it here </a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'appId'</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;YOURAPPID&quot;</span><span style="color: #339933;">,</span>
	  <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;APPSECRET&quot;</span><span style="color: #339933;">,</span>
	  <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$logoutUrl</span> <span style="color: #339933;">=</span>   <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLogoutUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$loginUrl</span>   <span style="color: #339933;">=</span>   <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		   <span style="color: #0000ff;">'canvas'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
		   <span style="color: #0000ff;">'fbconnect'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
		   <span style="color: #0000ff;">'req_perms'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'publish_stream,status_update,offline_access,publish_checkins'</span>
		   <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
	Thanks- application has been accepted
<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
	&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$loginUrl</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
	Login into Facebook to accept applicatioon
	 &lt;/a&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>   <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://graph.facebook.com/oauth/access_token&quot;</span><span style="color: #339933;">;</span> 		 
	 <span style="color: #000088;">$client_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;client_id&quot;</span><span style="color: #339933;">;</span> 		  
	 <span style="color: #000088;">$client_secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;app_id&quot;</span><span style="color: #339933;">;</span> 		  
	 <span style="color: #000088;">$postString</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;client_id=<span style="color: #006699; font-weight: bold;">$client_id</span>&amp;client_secret=<span style="color: #006699; font-weight: bold;">$client_secret</span>&amp;type=client_cred&amp;scope=email,publish_stream,offline_access,publish_checkins&quot;</span><span style="color: #339933;">;</span> 		 
<span style="color: #666666; font-style: italic;">//This first bit of code is to get the application a access token.</span>
<span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_FAILONERROR<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 		  <span style="color: #666666; font-style: italic;">//curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 		  curl_setopt($curl, CURLOPT_POST, 1); 		  curl_setopt($curl, CURLOPT_POSTFIELDS, $postString); 		  $response = curl_exec($curl); 	 		 		 $url = &quot;https://graph.facebook.com/&quot;.$FBID.&quot;/checkins&quot;; 		 $token = substr($response,13); 		   		  $attachment = array( 		   'access_token' =--&gt;  $token,</span>
		   <span style="color: #0000ff;">'place'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'place_ID'</span><span style="color: #339933;">,</span>
		   <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'I went to placename today'</span><span style="color: #339933;">,</span>
&nbsp;
		   <span style="color: #0000ff;">'picture'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://logo for post/'</span><span style="color: #339933;">,</span>
		   <span style="color: #0000ff;">'coordinates'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'latitude'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'lat'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'longitude'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'long'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'tags'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//tag a user to be tagged in as well</span>
&nbsp;
		<span style="color: #000088;">$attachment</span> <span style="color: #339933;">=</span>	<span style="color: #000088;">$attachment</span><span style="color: #339933;">;</span>
		  <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		  <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_SSL_VERIFYPEER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// This i added as the URL is https</span>
		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_SSL_VERIFYHOST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// This i added as the URL is https</span>
		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span>CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Do I need this ?</span>
		  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$attachment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #000088;">$result</span><span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #990000;">curl_close</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		  <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// some debug info</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The main problem i had with the code was to get the location details- the longitude and latitude had to be encoded as json- luckily php has a handy little tag for this which can turn a php array into json- you do not need to encode the whole attachment just the location details.</p>
<p>You can see with the post below- its a pretty normal post but it has tagged on the back of a map of the location. you can check out the docs here for adding more info to the  post- <a href="http://developers.facebook.com/docs/reference/api/checkin/"> Facebook checkin API DOC</a></p>
<p><a href="http://blog.justni.com/wp-content/uploads/2011/04/post.png"><img src="http://blog.justni.com/wp-content/uploads/2011/04/post.png" alt="" title="post" width="528" height="245" class="alignnone size-full wp-image-149" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/checking-in-to-facebook-using-the-graph-api-and-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to target potential clients using seo</title>
		<link>http://blog.justni.com/how-to-target-potential-clients-using-seo/</link>
		<comments>http://blog.justni.com/how-to-target-potential-clients-using-seo/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 15:22:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=135</guid>
		<description><![CDATA[The idea for this blog post came from me looking through the search terms that my website was receiving traffic from and i thought I would create an article to match the term- seems with a bit of research there is an poorly written article already out there, this post is going to share my [...]]]></description>
			<content:encoded><![CDATA[<p>The idea for this blog post came from me looking through the search terms that my website was receiving traffic from and i thought I would create an article to match the term- seems with a bit of research there is an poorly written article already out there, this post is going to share my knowledge and how I have gone about trying to get clients using SEO.</p>
<p>I am not going to give you basic SEO information like keyword research or where to put keywords, this post is more a strategy in how to target specific customers.</p>
<p><strong>Step one- Identify what you offer and what services your looking clients for </strong></p>
<p>What works best in SEO is highly targeted key term selection- if you are an accountant looking new clients- &#8220;accountant&#8221; would be a very competitive term rather than a specific service &#8220;Sole Trader Income Tax Preparation&#8221; which is a specific term and would be less competitive.</p>
<p>When you know specifically what services you offer the next step is to research which key terms to target. You can type the services you offer into somewhere like <a href="https://adwords.google.com/select/KeywordToolExternal">Google Keyword Tool</a> which will give you an idea of what people are searching for and give you some idea of terms you should be targeting. Every key term should then be put into a google search to identify how competitive the term is</p>
<p><strong>Step two- Build Pages</strong></p>
<p>The next step in the process is to take your key services key term and build pages explaining the service you offer and why a potential client should use your organisation.</p>
<p>I did this with <a href="http://justni.com">justni.com</a> and specifically a page like <a href="http://justni.com/facebook-apps-developer/">facebook apps developer</a> which targets the service I offer. My Ideal client for this is a design agency who may not have the technical skills that facebook apps require but have a client interested in developing an app.</p>
<p><strong>Step Three &#8211; Setup a blog and write about your sector/area</strong></p>
<p>As you can see, I have setup this blog on the sub domain of this website, but every post and page still links back to my main site, therefore any Google juice or burst in traffic I get to the blog is fed on to the main website. You do not have to write about your sector- you can post videos or pictures- an excellent example of a success story of this is <a href="http://tv.winelibrary.com/">wine library tv</a> where <a href="http://twitter.com/garyvee">@garyvee</a> made 1000 videos about wine and became  an internet celebrity (having almost 900k followers on twitter) while starting out with a camera and nothing else.</p>
<p><strong>Step four- Include a call to action</strong></p>
<p>When a user is browsing your page they should see something to click on where they can either contact you or find your contact details. I created a bold black button for this website on the right hand side which directs people to my contact page.</p>
<p>Do not leave it up to the user to find your contact details, make it bold, make it call out at the user- this will increase your conversion rate and in turn increase your leads generated.</p>
<p><strong>Step five- KILLER no1 TIP for SEO-</strong></p>
<p>Create great content! that&#8217;s it&#8230; if you can create great content that people want to share, thats 90% of the battle- if your rinsing other peoples content and trying to take the copy and paste approach- it will not work. Users/consumers like new, fresh and innovative ideas, that&#8217;s why the godfather isn&#8217;t stuck at Amazon&#8217;s no.1 spot all the time- people like new things! Gary Vaynerchuck won because he created fun and innovative content around wine which people perceive as a stuck up sector. My favourite episode was where Gary compared what wine went with breakfast cereal- <a href="http://tv.winelibrary.com/?p=4123">see it here</a>- There ya go.. a point just proved.</p>
<p><strong>Step six &#8211; Persist and Persevere</strong></p>
<p>SEO is a slow process- like life, the older the person the wiser the person is (meant to be). Google ranks content using this same principle, as your domain/content ages it will rank higher than new or fresh content. Unless your domain carries a lot of authority, new content will take a while to rank.</p>
<p>If you add one post a week for a year, you will have 52 posts by a year end- if each posts receives 4 hits a week = that&#8217;s 208 a week! For my business, one enquiry a week would keep my business going, usually much less than this. For any small business 1000/hits per month to their Blog is an ample amount of traffic to keep them going</p>
<p>Fine me on twitter at <a href="http://twitter.com/yrecruit_chris">@yrecruit_chris</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/how-to-target-potential-clients-using-seo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making your Facebook shares better/prettier</title>
		<link>http://blog.justni.com/making-your-facebook-shares-better-prettier/</link>
		<comments>http://blog.justni.com/making-your-facebook-shares-better-prettier/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 13:32:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=126</guid>
		<description><![CDATA[If your running a website and actively encourage users to share ccntent across facebook, it may be a good idea to control what way its being shared. Facebook includes graph meta tags which allow you to default to a certain image for the post on facebook and what title.
Add these tags between the &#60;head&#62; tags [...]]]></description>
			<content:encoded><![CDATA[<p>If your running a website and actively encourage users to share ccntent across facebook, it may be a good idea to control what way its being shared. Facebook includes graph meta tags which allow you to default to a certain image for the post on facebook and what title.</p>
<p>Add these tags between the &lt;head&gt; tags on your page</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;meta property=&quot;og:type&quot; content=&quot;blog&quot; /&gt;
&lt;meta property=&quot;og:url&quot; content=&quot;http://blog.yrecruit.com/2011/03/the-state-of-online-recruitment-websites-in-ireland/&quot; /&gt;
&lt;meta property=&quot;og:site_name&quot; content=&quot;Yrecruit Blog&quot; /&gt;
&lt;meta property=&quot;og:image&quot; content=&quot;http://yrecruit.com/imgs/yrecruit_share.png&quot;/&gt;</pre></td></tr></table></div>

<p>This is the content for the tags on one of my new sites which enables a logo to be displayed along with the title, if i didnt have that tag included, the logo would not be displayed at all.</p>
<p>Now my post looks like this without the logo</p>
<p><a href="http://blog.justni.com/wp-content/uploads/2011/03/postwithout.png"><img class="alignnone size-full wp-image-128" title="postwithout" src="http://blog.justni.com/wp-content/uploads/2011/03/postwithout.png" alt="" width="512" height="288" /></a></p>
<p>Having added in the tags now i get a pretty branded logo included with my blog post</p>
<p><a href="http://blog.justni.com/wp-content/uploads/2011/03/postwithimage.png"><img class="alignnone size-full wp-image-129" title="postwithimage" src="http://blog.justni.com/wp-content/uploads/2011/03/postwithimage.png" alt="" width="512" height="288" /></a></p>
<h2>Plugins for wordpress</h2>
<p>Manually putting this on every page would be tedious and time consuming, luckily i use wordpress to power my blogs and it comes with a handy tool to include the tags.</p>
<p>The plugin i use is listed below-<br />
<a href="http://wordpress.org/extend/plugins/opengraph/">Open Graph</a><br />
<a href="http://wordpress.org/extend/plugins/opengraph/">Add Open Graph metadata to your pages.</a></p>
<p>I added in my own image tag to the header file of my theme and made sure the image worked with the posts</p>
<h2>For more info</h2>
<p>Check out the page on<a href="http://developers.facebook.com/docs/reference/plugins/like/"> facebook.com </a>about sharing content</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/making-your-facebook-shares-better-prettier/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Facebooks best kept secret- insights for domain</title>
		<link>http://blog.justni.com/facebooks-best-kept-secret-insights-for-domain/</link>
		<comments>http://blog.justni.com/facebooks-best-kept-secret-insights-for-domain/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 12:35:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[facebook tips]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=119</guid>
		<description><![CDATA[Facebook launched insights for domains external to Facebook last June and people are still not using them, very few people I know are using them and I thought I would share.
Why use facebook insights for you domain?
If you blog or own a domain with sharable content such as video and mp3&#8217;s facebook insights for your [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook launched insights for domains external to Facebook last June and people are still not using them, very few people I know are using them and I thought I would share.</p>
<h3>Why use facebook insights for you domain?</h3>
<p>If you blog or own a domain with sharable content such as video and mp3&#8217;s facebook insights for your domain will allow you see analytics on what is the most shared content and provide an insight into your content in a dashboard like styley..</p>
<h3>Setting up Facebook insights for your domain</h3>
<p>You need to move over to facebok - <a href="http://www.facebook.com/insights/">http://www.facebook.com/insights/</a> And at the top of the page you will see the green button for &#8220;Insights for your domain&#8221;. And you should be presented with the following popup box which will display a little meta tag that should be added to your domains index page &lt;head&gt; tag.</p>
<p><a href="http://blog.justni.com/wp-content/uploads/2011/02/input-your-domain.jpg"><img class="alignnone size-full wp-image-120" title="input-your-domain" src="http://blog.justni.com/wp-content/uploads/2011/02/input-your-domain.jpg" alt="" width="494" height="392" /></a></p>
<p>Place this meta tag into your html document- this is mine- excluding my FB id of course. Place it somewhere between your &lt;head&gt; tags -</p>
<p>&lt;meta property=&#8221;fb:admins&#8221; content=&#8221;yourfbid&#8221; /&gt;</p>
<p>Now click on &#8220;check domain&#8221; button and Facebook will grab your domain to see if there is a corresponding admin ID, if it matches yours, you will be granted full insights into your domains</p>
<p><a href="http://blog.justni.com/wp-content/uploads/2011/02/view.png"><img class="alignnone size-full wp-image-122" title="view" src="http://blog.justni.com/wp-content/uploads/2011/02/view.png" alt="" width="600" height="315" /></a></p>
<p>Facebook will let view how many impressions your links/flash files/images got when they were shared, this is vital if your website is built around sharing and social media.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/facebooks-best-kept-secret-insights-for-domain/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web Application Development for Ferrari</title>
		<link>http://blog.justni.com/web-application-development-for-ferrari/</link>
		<comments>http://blog.justni.com/web-application-development-for-ferrari/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 12:58:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=112</guid>
		<description><![CDATA[I recently completed an web application for Ferrari in conjunction with Jason Dean at TheMews.tv for his client Pierce SmartFusion NewYork. This was a demanding app due to the quick turnaround time required and feature specification changes but its great to work on something that was so intricate and mission critical (a lot of people will [...]]]></description>
			<content:encoded><![CDATA[<p>I recently completed an web application for Ferrari in conjunction with Jason Dean at <a href="http://www.themews.tv">TheMews.tv</a> for his client <a href="http://www.piercesmartfusion.com/">Pierce SmartFusion</a> NewYork. This was a demanding app due to the quick turnaround time required and feature specification changes but its great to work on something that was so intricate and mission critical (a lot of people will be using the application)</p>
<h2>What it was for</h2>
<p style="text-align: center;"><a href="http://blog.justni.com/wp-content/uploads/2011/02/ferrari.jpg"><img class="size-full wp-image-115 aligncenter" title="ferrari" src="http://blog.justni.com/wp-content/uploads/2011/02/ferrari.jpg" alt="" width="600" height="331" /></a></p>
<p>The main core of the application was to allow potential Ferrari customers to book a test drive and experience a new car that Ferrari was launching. A mailing list was already build that had the web address of the application where a user could import the code that they where suplied with and booking a time slot that they where free on a specific date to test drive the car.</p>
<p>The main features of the application</p>
<ul>
<li>Allow people who were identified to book a car at a specific time and venue.</li>
<li>Allow Ferrari to track who made bookings and where</li>
<li>Allow Ferrari to rate the customers on the likelihood of the participant in making a purchase.</li>
<li>Allow participants to register when they arrived using an ipad version of the website</li>
</ul>
<p>This doesn&#8217;t sound complicated at all but with only 4 cars available, at certain dates, multiple venues and thousands of potential users the system cant get very complicated very quickly.</p>
<h2>Build process</h2>
<p>The normal build process that most applications whether it be for web, mobile or even facebook is that I am supplied with images of the layout and specification document then it is up to me to turn these two pieces in to a work application.</p>
<p>With the client on Skype liaising with myself and the Ferrari guys, we were able to test the application thoroughly and make the feature requests and changes the same day.</p>
<h2>Tools and technology used</h2>
<p>To complete this project the basic stack that was used for the web application was-</p>
<ul>
<li>php/mysql combo</li>
<li>codeigniter 1.7</li>
<li>Blueprint (css for the admin)</li>
<li>I also used simplesecurelogin for user login management with CI</li>
</ul>
<p>As always my development environment is -</p>
<ul>
<li>2 machines, one running windows 7 and one running windows xp</li>
<li>Notepad++</li>
<li>Xampp</li>
<li>photoshop /filezilla</li>
</ul>
<p>Other tools include Gmail and skype for communications and to do lists. I also use synergy across my two machines, it allows me to run a 3 monitor setup using the same keyboard and mouse for all three, freeing up desk space</p>
<h2>Obstacles Overcome</h2>
<p>There was quite a few obstacles to overcome in this project and i have listed them below and how the project was successfully delivered.</p>
<ul>
<li>User experience- a lot of the time, no one plans what an admin section is to have, there is a lot of data in this system and a lot to be viewed. The original designs worked well but limited the user experience, I suggested a few tweaks and the user experience for the user was improved</li>
<li>Multiple sources of data, The importation of the customer lists came from multiple different sources with varying formatting. Using php&#8217;s inbuilt functions, code could be written quickly to overcome this obstacle.</li>
<li>Dates, times and cars. This was a major problem, it was a mission critical kind of problem where you couldn&#8217;t have multiple bookings more than 4 as there was only 4 cars available. With multiple cars available at multiple times on multiple dates at multiple venues the system could have easily got out of hand but with continual testing something similar to TDD, iterations were made quickly to build a scalable application</li>
<li>iPad view. I do not own many apple products and I certainly do not use an ipad, but one of the requirements was to allow users to register when they arrive at their specified time slot. I had never done an IPad application but I took the original design and scaled it to match the screen resolution provided by the iPad and the client reported back that the application worked well.</li>
<li>Speed of delivery. Accommodating tight deadlines is always troublesome when your a freelance solo developer. I put a lot of time in to the development of this application and often worked late to accommodate changes, I enjoy what I do therefore its not often a problem. The advantage in this project was that it was going to be used in California and since I live in Ireland, i can almost get a full days work in before the guys in California are even out of bed!</li>
</ul>
<h2>Conclusions</h2>
<p>Although this project was stressful, its good to see something that I built from scratch being used by such a huge brand name. Its great to look out a dreary, miserable, window in Ireland and look back at your machine to input details of Beverly Hills and Ferraris <img src='http://blog.justni.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you have a web application requirement email me chris@justni.com</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/web-application-development-for-ferrari/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Facebook applications case study</title>
		<link>http://blog.justni.com/facebook-applications-case-study/</link>
		<comments>http://blog.justni.com/facebook-applications-case-study/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 12:38:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=107</guid>
		<description><![CDATA[Got sent this by a potential client today who wants something very similar,  I thought I would share it  It&#8217;s one of the best case studies I have seen for Facebook application development and user adoption of a branded application.

I have pitched this idea before to clients and they havent gone for it.  Now i have [...]]]></description>
			<content:encoded><![CDATA[<p>Got sent this by a potential client today who wants something very similar,  I thought I would share it  It&#8217;s one of the best case studies I have seen for Facebook application development and user adoption of a branded application.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/Zd5pFwmYabI?fs=1&amp;hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Zd5pFwmYabI?fs=1&amp;hl=en_GB" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>I have pitched this idea before to clients and they havent gone for it.  Now i have this case study to back up the idea!</p>
<p>I have built similar applications in the past to client specification which didn&#8217;t have as many features. If you are a brand would like to work with me on something like this- email me- chris@justni.com I would love to build something like this for a big brand.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/facebook-applications-case-study/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for being a freelancer</title>
		<link>http://blog.justni.com/tips-for-being-a-freelancer/</link>
		<comments>http://blog.justni.com/tips-for-being-a-freelancer/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 01:40:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.justni.com/?p=103</guid>
		<description><![CDATA[I have been meaning to blog about this for a while, i have pretty much been working as a freelance developer for about a year now and this is a way to document the good, the bad, the highs and the lows.
The do&#8217;s

Marketing- identify what works best for you, is it networking? Is it cold [...]]]></description>
			<content:encoded><![CDATA[<p>I have been meaning to blog about this for a while, i have pretty much been working as a freelance developer for about a year now and this is a way to document the good, the bad, the highs and the lows.</p>
<p><strong>The do&#8217;s</strong></p>
<ul>
<li><strong>Marketing</strong>- identify what works best for you, is it networking? Is it cold calling? Is it blogging? for me, its Google Adwords, i pay around $4.50/£3 a click and it gives me a high return and best quality leads. I mainly develop small facebook applications and the return on money spent is around 30 to 1</li>
<li><strong>Avoiding procrastination</strong> &#8211; I worked from home for the most part of the year and eventually went into a shared office space around October. My output went through the roof, I left most of the distractions in my life at home. GET AN OFFICE! I started making lists every morning which is a tip i got from a sales book and it works. Recently speaking to a HR consultant from <a href="http://www.handsonhr.ie">HandsOnHR.ie</a> who told me, even if he is working from home that day he will still put on a shirt and a tie which puts his mind into work mode.</li>
<li><strong>Get to event</strong>s- you can only learn so much from books and online, getting to talk to other developers or business people can help you develop your skills set while giving your a fresh outlook on things.</li>
<li><strong>Learn a framework</strong>- This is a developer tip, when I started out i wrote straight php for all the applications and when I recently went to make amendments on code i wrote 10 months ago, my eyes hurt! The code had no order and was poorly structured, I now write all my apps using <a href="http://codeigniter.com/">codeigniter </a> Which gives me a framework to develop  to, using the MVC my code is cleaner, other people can come along and write to the same standard and also means i can reuse a lot of the code.</li>
<li><strong>Pricing</strong> &#8211; put your prices, no matter what you put them up now! Golden rule, unless your being told your too expensive at least once a month your too cheap! Its a harsh reality but higher priced developers arnt always better developers but they are a lot more respected. When i was cheaper&#8230; clients seen this as a sign of weakness and I felt they took advantage of my good nature. If they want extra services, charge for it. Its a business your running, not a charity.</li>
<li><strong>Identify your ideal customers</strong>- a year ago i would have told you my ideal customer/client was someone with money. Now my ideal customer is a design agency who has already sold the application and has all the resources and assets ready for you to go.  Spending a week trying to sell an application to a hotel that have little or no knowledge of the web let alone what you do is wasting your time. Go after the low hanging fruit and gear your marketing around this.</li>
<li><strong>Meet people</strong>- Some people are just out for themselves and too make a quick buck, but there are many others who are out there to be successful and no better feeling that helping someone else reach success. Finding people who generally want to help you will not only keep you sane but help your business. You can find these at networking groups or events even if they are in a completely unrelated industry to yours, genuine people are in all kinds of businesses. Meeting people can provide support, insights and a fresh prospective on ideas/business</li>
</ul>
<p><strong>The do not&#8217;s</strong></p>
<ul>
<li><strong>Bite of more than you can chew &#8211; </strong>Find something your good at and work with that, I took on flash work last year which I was going to use to try and learn flash, i spent 6 weeks messing around with flash which got me nowhere and no money.</li>
<li><strong>Ignore your instincts</strong>- When someone says &#8220;I need to get a deposit of my mom&#8221; or when a client struggles to come up with a small deposit, walk away, these are nuisance clients who will not respect your time and may not even pay you</li>
<li><strong>For the money</strong>- I recently talked to students and the message i tried to convey when starting up a business was, don&#8217;t just do it for the money. You will be working more hours, working all night and getting yourself nowhere. If you have family and friends, it will strain your relationships and personally I value my friendships more than any money.</li>
<li><strong>Let people walk all over you</strong>- I was raised to be nice, I was raised to be told what to do and never question anyone. This is not the personality/mentality  you want when your in business. Business can often be ruthless and cruel, live with it, adapt and you will come out the other end stronger. But being self employed and having that freedom can often outweigh any bad points</li>
</ul>
<p>So to recap on the last year, here&#8217;s what the highlights/lowpoints have been for me</p>
<p><strong>Highlights</strong></p>
<ul>
<li><strong>The projects I work on-</strong> Some of the work I have done over the last year has been really interesting and pushed my skills to the extreme. From just the normal facebook tab applications to virtual postcards for facebook right through to offline facebook &#8220;like&#8221; buttons and donation mechanisms through facebook.</li>
<li><strong>The people I worked with</strong> &#8211; In the past year I have worked with some truly inspiring people, not only their drive and determination but just their for being fun and being able to sit on the phone for 20 mins talking about stuff other than work to help realise there is more to life than creating the next killer idea.</li>
<li><strong>The people I met</strong>- I have met some of the nicest people ever, truly inspirational who I will never do work for but would happily go for a meal or drinks with.</li>
<li><strong>The happy customers</strong>- Many things have made me smile over the last year including one email from a client that opened with &#8220;Dude, i love you&#8221; you can&#8217;t get much happier than that.</li>
<li><strong>Award winning</strong>- Although I haven&#8217;t won any awards myself, one of my clients has, which is great to know you had an impact on helping their vision gain a  tangible reality.</li>
</ul>
<p><strong>The low points</strong></p>
<ul>
<li><strong>Not getting paid </strong>- This has been a lesson, going back to a point earlier, trust your gut, if something seems fishy accept 100% upfront and no less. Waying up pursuing bad debts is another problem, is there much value in chasing small debts when it costs money and time to do so. Luckily out of about 30 clients only 2 haven&#8217;t paid me. Talking over the problem with other businesses, it can be a problem even paying a debt collector when the client actually has no money, you could be wasting money</li>
<li><strong>Taking on deb</strong>t- most businesses need some level of debt to pay people or buy equipment while awaiting getting paid themselves, often an overdraft or credit card can help in this period. But at one point I was about 5k in debt last year and that can be a burden for anyone</li>
<li><strong>Being sick</strong>- When its just you in a business and you have set deadlines being sick is the worst thing to happen. I have missed opportunities due to having the worst case of the flu in my life. Some people like to think of me as a machine that never breaks down but  but often overworking, late nights mixed with early mornings can affect you mentally and have an impact on your immune system.</li>
</ul>
<p><strong>Conclusion</strong></p>
<p>I have met some inspirational people, worked on cool stuff and learnt many lessons, but is it really for me? I love coding but I love being out around people. I also spent many years toying with internet marketing and the numbers game being something I enjoyed.</p>
<p>For me to make the most money out of what I do would mean I staying in the office and never leaving. I have met only a few of my clients and I could truely work from anywhere with an internet connection. I often say to people I could work from a tent on top of a mountain. When I start going out to meet clients I am loosing my daily rate, its easier to develop sales and application ideas remotely through skype, over the phone and email. When i do get out for meetings i try to cram in as many in one day as possible</p>
<p>Whats next? I am trying to build a business that encompasses all what I enjoy from networking and being around people to coding and internet marketing. I feel that pushing towards developing a product would do this. therefore I started developing two ideas I had.</p>
<p>First one is a action based crm, a crm that has been stripped to its barebones and a very basic UI. Still in development but 70% there, needs a name though</p>
<p>Second one has a name- <a href="http://www.yrecruit.com">http://www.yrecruit.com</a> will be a job search engine providing a better more cost affective experience on both ends. stay tuned.. (Thanks to <a href="http://www.mdd.ie">Mdd.ie</a> for the logo design)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justni.com/tips-for-being-a-freelancer/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
