<?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>Emran Hasan&#039;s Blog &#187; Web Development</title>
	<atom:link href="http://phpfour.com/blog/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpfour.com/blog</link>
	<description>The everyday sharing of Emran Hasan on software development.</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:39:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>To me design is&#8230;</title>
		<link>http://phpfour.com/blog/2012/01/to-me-design-is/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=to-me-design-is</link>
		<comments>http://phpfour.com/blog/2012/01/to-me-design-is/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 16:16:59 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=432</guid>
		<description><![CDATA[A great compilation by Vostok Studios on what great designers think about design.]]></description>
			<content:encoded><![CDATA[<p>A great compilation by <a href="http://www.vostokstudio.com/" target="_blank">Vostok Studios</a> on what great designers think about <em>design</em>.</p>
<p><iframe src="http://player.vimeo.com/video/17995436?title=0&amp;byline=0&amp;portrait=0" frameborder="0" width="610" height="350"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2012/01/to-me-design-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Painless Ruby and Rails installation on Ubuntu/Mint</title>
		<link>http://phpfour.com/blog/2011/06/painless-ruby-and-rails-installation-on-ubuntumint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=painless-ruby-and-rails-installation-on-ubuntumint</link>
		<comments>http://phpfour.com/blog/2011/06/painless-ruby-and-rails-installation-on-ubuntumint/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 05:28:16 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=384</guid>
		<description><![CDATA[It took me an hour to properly install the latest versions of ruby, rails and its mysql binder. Although its less than a 5 mins task, I had to search in forums, blogs to deal with the various errors. So just posting this so its easy for someone else to get done with this in [...]]]></description>
			<content:encoded><![CDATA[<p>It took me an hour to properly install the latest versions of ruby, rails and its mysql binder. Although its less than a 5 mins task, I had to search in forums, blogs to deal with the various errors. So just posting this so its easy for someone else to get done with this in 5 mins.</p>
<p>1. Open Terminal and install <a href="https://rvm.beginrescueend.com/" target="_blank">RVM (Ruby Version Manager)</a></p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>install<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
<p>2. Enter the following in ~/.bash_profile and/or ~/.bashrc (replace YOUR USER NAME with the username you&#8217;re logged in with):</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;/home/YOUR USER NAME/.rvm/scripts/rvm&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #ff0000;">&quot;/home/YOUR USER NAME/.rvm/scripts/rvm&quot;</span> &nbsp;<span style="color: #666666; font-style: italic;"># This loads RVM into a shell session.</span></div></div>
<p>3. Install Ruby 1.9.2</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2</div></div>
<p><span id="more-384"></span><br />
4. Set it as the ruby version to use through rvm:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rvm use 1.9.2</div></div>
<p>5. Install latest version of Rails:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</div></div>
<p>6. Install mysql bindings:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> libmysql-ruby libmysqlclient-dev<br />
gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql</div></div>
<p>7. Now you should be able to create a rails project with mysql binding:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rails new hello<br />
bundle <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2011/06/painless-ruby-and-rails-installation-on-ubuntumint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing better PHP projects</title>
		<link>http://phpfour.com/blog/2010/11/developing-better-php-projects/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=developing-better-php-projects</link>
		<comments>http://phpfour.com/blog/2010/11/developing-better-php-projects/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 14:45:25 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[best-practice]]></category>
		<category><![CDATA[coding techniques]]></category>
		<category><![CDATA[phpxperts]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=302</guid>
		<description><![CDATA[I presented this talk yesterday on the phpXperts seminar 2010 &#8211; the largest PHP group in Bangladesh. My objective was to give a quick overview on project structure, development practices and use of tools to improve the overall quality of the PHP projects. So here goes the presentation:]]></description>
			<content:encoded><![CDATA[<p>I presented this talk yesterday on the phpXperts seminar 2010 &#8211; the largest PHP group in Bangladesh. My objective was to give a quick overview on project structure, development practices and use of tools to improve the overall quality of the PHP projects.</p>
<p>So here goes the presentation:</p>
<div style="width:425px; text-align: center; margin: 0 auto;" id="__ss_5688159"><object id="__sse5688159" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=developingbetterphpprojects-101106140513-phpapp01&#038;stripped_title=developing-better-php-projects&#038;userName=phpfour" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5688159" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=developingbetterphpprojects-101106140513-phpapp01&#038;stripped_title=developing-better-php-projects&#038;userName=phpfour" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2010/11/developing-better-php-projects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quick start on new Facebook PHP SDK (IFrame based)</title>
		<link>http://phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-start-on-new-facebook-php-sdk-iframe-based</link>
		<comments>http://phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/#comments</comments>
		<pubDate>Mon, 03 May 2010 20:39:46 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Graph API]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=278</guid>
		<description><![CDATA[This post is more than 1 year old. It solved the issues when the SDK was first released and facebook had lack of documentation. However, now facebook has very rich set of documnetation and you should follow that instead! The new Facebook API has already spread over the application developers and if you&#8217;re like me, [...]]]></description>
			<content:encoded><![CDATA[<div style="color: #fff; background-color: #AE0700; padding: 10px; text-align:justify;">This post is more than 1 year old. It solved the issues when the SDK was first released and facebook had lack of documentation. However, now facebook has very rich set of <a href="http://developers.facebook.com/docs/">documnetation</a> and you should follow that instead!</div>
<p>The new <a href="http://developers.facebook.com/docs/" target="_blank">Facebook API</a> has already spread over the application developers and if you&#8217;re like me, you&#8217;ve already got your hands dirty to see how this new thing works. If you have tried to follow the documentation to <a href="http://developers.facebook.com/docs/guides/canvas/#auth" target="_blank">authorize/get session</a> in your canvas application, it is likely you have already hit roadblocks. Well, I am no savior but I have glued together a few clues and got it working for myself.</p>
<p>I am assuming that you have already created your application by following the <a href="http://developers.facebook.com/docs/guides/canvas/#canvas" target="_blank">Getting Started</a> section from the official documentation. Also, this is for <strong>IFrame based</strong> applications only.</p>
<p>Enough talking, let&#8217;s get some code.</p>
<p><strong><span style="text-decoration: underline;">Step 1: Get the new SDK</span></strong></p>
<p>Download the new SDK from <a href="http://github.com/facebook/php-sdk/" target="_blank">github</a>. We will only need the <strong>facebook.php</strong> file from the <strong>src</strong> folder. In our project directory, let&#8217;s create a folder called &#8220;lib&#8221; and put the file there.</p>
<p><strong><span style="text-decoration: underline;">Step 2: A configuration file</span></strong></p>
<p>Let&#8217;s now create a configuration file to store our facebook configuration. Let&#8217;s name it <strong>config.php</strong>. Here goes the source:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_APP_ID&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'113795715321151'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_API_KEY&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'064baf5fb98de050cd7b9a001ca1988b'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_SECRET_KEY&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'430f43c01f6dfe02c284b4545976f9ce'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;FACEBOOK_CANVAS_URL&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://apps.facebook.com/emran-test-app/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><strong><span style="text-decoration: underline;">Step 3: Application Main Page</span></strong></p>
<p>This file will be the main entry point to our facebook application. It just instantiates the facebook object, sets the configuration and checks for a valid session. If it does not find a valid session, it redirects to the login page. For first time visitors, it will be the authorization page. On later requests, the operation will occur in the background &#8211; without any user interaction.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'lib/facebook.php'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'config.php'</span><span style="color: #339933;">;</span><br />
<br />
<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><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'appId'</span> &nbsp;<span style="color: #339933;">=&gt;</span> FACEBOOK_APP_ID<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> FACEBOOK_SECRET_KEY<span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'phpfour.com'</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$session</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000088;">$url</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><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'canvas'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'fbconnect'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;script type='text/javascript'&gt;top.location.href = '<span style="color: #006699; font-weight: bold;">$url</span>';&lt;/script&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; try <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$me</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$updated</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, F j, Y&quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'updated_time'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You last updated your profile on &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$updated</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>FacebookApiException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><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><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-278"></span></p>
<p>You might be wondering &#8211; it&#8217;s pretty straight-forward, so what&#8217;s the catch ? Well, to be honest, the documentation does not have the &#8220;canvas&#8221; parameter mentioned anywhere which does the primary magic here. Also, if you do not use the javascript trick, then you end up with an authorization dialog with full facebook UI within the iframe itself (see below).</p>
<p><a href="http://www.phpfour.com/img/fb-auth-without-js.png"><img class="aligncenter size-medium wp-image-281" title="Auth without JS redirect" src="http://www.phpfour.com/img/fb-auth-without-js.png" alt="" width="300" height="213" /></a></p>
<p><strong><span style="text-decoration: underline;">CodeIgniter Version</span></strong></p>
<p>Here is the CodeIgniter version of the above example. The significance is that CodeIgniter removes the values from the $_GET super global &#8211; which is required for the library to work. We thus re-populate it on the constructor ourselves and start a session to share data among subsequent page visits.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #b1b100;">include_once</span> APPPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'libraries/facebook-php-sdk/facebook.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #000000; font-weight: bold;">extends</span> Controller<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/parse_str"><span style="color: #990000;">parse_str</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'appId'</span> &nbsp;<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'facebook_app_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'secret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'facebook_secret_key'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'cookie'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'phpfour.com'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$session</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$session</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLoginUrl</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'canvas'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fbconnect'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;script type='text/javascript'&gt;top.location.href = '<span style="color: #006699; font-weight: bold;">$url</span>';&lt;/script&gt;&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$uid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$me</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$updated</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, F j, Y&quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'updated_time'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$me</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;You last updated your profile on &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$updated</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>FacebookApiException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error:&quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><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><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Hope I am able to help a few people.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/feed/</wfw:commentRss>
		<slash:comments>206</slash:comments>
		</item>
		<item>
		<title>Enterprise PHP</title>
		<link>http://phpfour.com/blog/2010/02/enterprise-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=enterprise-php</link>
		<comments>http://phpfour.com/blog/2010/02/enterprise-php/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 12:11:13 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[enterprise]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[softexpo]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=273</guid>
		<description><![CDATA[I presented this talk on the Soft Expo 2010 &#8211; the largest software fair in Bangladesh. The intention was to clear some of the misconception about PHP, the growth of PHP, how it can fit in the enterprise now, etc. After these, I shed light on some topics that a company/developer should keep in mind [...]]]></description>
			<content:encoded><![CDATA[<p>I presented this talk on the Soft Expo 2010 &#8211; the largest software fair in Bangladesh. The intention was to clear some of the misconception about PHP, the growth of PHP, how it can fit in the enterprise now, etc.</p>
<p>After these, I shed light on some topics that a company/developer should keep in mind in order to write good software in PHP. This was followed by live session on caching, mysql query optimization, use of Xdebug, etc.</p>
<p>So here goes the presentation:</p>
<div style="margin: 0pt auto; width:425px; text-align: center;" id="__ss_3176537"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=enterprisephp-100214110838-phpapp01&#038;stripped_title=enterprise-php-3176537" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=enterprisephp-100214110838-phpapp01&#038;stripped_title=enterprise-php-3176537" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>And a big thanks to Ivo Jansch&#8217;s &#8220;<a href="http://www.slideshare.net/ijansch/php-in-the-real-world">PHP in the real wolrd</a>&#8221; presentation, from where I took inspiration.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2010/02/enterprise-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Changing the default controller naming convention in CodeIgniter</title>
		<link>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codeigniter-controller-naming-convention-modified</link>
		<comments>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 06:23:04 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=265</guid>
		<description><![CDATA[CodeIgniter is one of my favorite framework and I often use it for developing application quickly. Although it is very flexible in most cases, I find its naming convention to be strict. Many times I have faced this problem when my controller&#8217;s class name and a model/library&#8217;s class names are the same &#8211; a Fatal [...]]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter is one of my favorite framework and I often use it for developing application quickly. Although it is very flexible in most cases, I find its naming convention to be strict. Many times I have faced this problem when my controller&#8217;s class name and a model/library&#8217;s class names are the same &#8211; a Fatal error is inevitable and I have to forcefully change the name of the conflicting class to something less desirable (say from Users to UsersModel). Today I wanted to end this problem.</p>
<p>So I extended the <strong>CI_Router</strong> core class and made change to the <em>_validate_request</em> method. Now I can name my controller classes in this fashion: <strong>UsersController</strong> and it resides on the file system as <strong>controllers/UsersController.php</strong>. If you&#8217;ve tried other established frameworks, you should notice that this naming convention is widely used. So, if you have the same need, then just download the MY_Router.php file and put it on your application/libraries folder. That&#8217;s it.</p>
<p>Here is how your controller would start:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> UsersController <span style="color: #000000; font-weight: bold;">extends</span> Controller<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><span id="more-265"></span><br />
If you&#8217;d like to have a look at the code, here is the source for quick view:</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/defined"><span style="color: #990000;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
&nbsp;* MY_Router<br />
&nbsp;*<br />
&nbsp;* Extended the core CI_Router class in order to force a different naming<br />
&nbsp;* convention for controllers.<br />
&nbsp;*<br />
&nbsp;*/</span><br />
<span style="color: #000000; font-weight: bold;">class</span> MY_Router <span style="color: #000000; font-weight: bold;">extends</span> CI_Router<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Suffix in controller name<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @var String<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_suffix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Controller&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Call the parent constructor<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* This is a requirement for extending base CI core class. Just abiding by<br />
&nbsp; &nbsp; &nbsp;* the rules.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @access &nbsp;public<br />
&nbsp; &nbsp; &nbsp;* @return &nbsp;void<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MY_Router<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parent<span style="color: #339933;">::</span><span style="color: #004000;">CI_Router</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Validates the supplied segments. &nbsp;Attempts to determine the path to<br />
&nbsp; &nbsp; &nbsp;* the controller.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @access &nbsp; private<br />
&nbsp; &nbsp; &nbsp;* @param &nbsp; &nbsp;array<br />
&nbsp; &nbsp; &nbsp;* @return &nbsp; array<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> _validate_request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Retain the original segments</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$orgSegments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</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: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the requested controller exist in the root folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$segments</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// OK, revert to the original segment</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$orgSegments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Is the controller in a sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</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;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the directory and remove it from the segment array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_directory</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</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: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_slice"><span style="color: #990000;">array_slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</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: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the requested controller exist in the sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show_404<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$segments</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: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add suffix to the end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ucfirst"><span style="color: #990000;">ucfirst</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_suffix<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_class</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_controller</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_method</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Does the default controller exist in the sub-folder?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span>APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'controllers/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_directory</span><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;">default_controller</span><span style="color: #339933;">.</span>EXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">directory</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$segments</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Can't find the requested controller...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; show_404<span style="color: #009900;">&#40;</span><span style="color: #000088;">$segments</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: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/09/codeigniter-controller-naming-convention-modified/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Facebook Developer Garage Dhaka – Open Stream API</title>
		<link>http://phpfour.com/blog/2009/08/facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish</link>
		<comments>http://phpfour.com/blog/2009/08/facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 03:26:05 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[facebook garage]]></category>
		<category><![CDATA[open stream]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=255</guid>
		<description><![CDATA[The first ever &#8220;Facebook Developer Garage&#8221; took place in Dhaka, Bangladesh and I am proud to be a part of it. I was one of the speakers of this spectacular event organized by Facebook and IBT bangladesh. I spoke about the recently released Open Stream API from Facebook. It was more of an overview rather [...]]]></description>
			<content:encoded><![CDATA[<p>The first ever &#8220;Facebook Developer Garage&#8221; took place in Dhaka, Bangladesh and I am proud to be a part of it. I was one of the speakers of this spectacular event organized by Facebook and IBT bangladesh. I spoke about the recently released Open Stream API from Facebook. It was more of an overview rather than a detail one. Here goes the slides:</p>
<div style="margin: 0pt auto; width:425px; text-align: center;" id="__ss_1898723"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=facebookgarage-090824045242-phpapp01&#038;stripped_title=facebook-open-stream-api-facebook-developer-garage-dhaka" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=facebookgarage-090824045242-phpapp01&#038;stripped_title=facebook-open-stream-api-facebook-developer-garage-dhaka" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>I have created a quick start example which outlines both Facebook Connect and the Open Stream API. You can check that <a href="http://www.phpfour.com/fbstream/">here</a>. A blog post covering the steps is coming soon in 3-4 days.</p>
<p>Stay tuned if you have interest in them.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/08/facebook-developer-garage-dhaka-open-stream-api-connect-quickstart-publish/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>phpXperts &#8217;09 seminar</title>
		<link>http://phpfour.com/blog/2009/05/phpxperts-09-seminar-becoming-a-php-ninja/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=phpxperts-09-seminar-becoming-a-php-ninja</link>
		<comments>http://phpfour.com/blog/2009/05/phpxperts-09-seminar-becoming-a-php-ninja/#comments</comments>
		<pubDate>Sun, 17 May 2009 12:29:25 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[phpxperts]]></category>
		<category><![CDATA[seminar]]></category>
		<category><![CDATA[speech]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=243</guid>
		<description><![CDATA[At last the phpXperts seminar on &#8220;Current Web Trends&#8221; have taken place and I was one of the speakers there. Among all the topics, mine was a bit suggestive and naturally a bit less exciting. I spoke about how to become a PHP ninja &#8211; what are the characteristics they posses, what are the tools [...]]]></description>
			<content:encoded><![CDATA[<p>At last the phpXperts seminar on &#8220;Current Web Trends&#8221; have taken place and I was one of the speakers there. Among all the topics, mine was a bit suggestive and naturally a bit less exciting. I spoke about how to become a PHP ninja &#8211; what are the characteristics they posses, what are the tools they use, what are the paths they follow etc. It&#8217;s actually a follow-up of one of my blog posts: &#8220;<a href="http://www.phpfour.com/blog/2008/10/become-kick-ass-php-ninja-from-newbie-guide-tips/">Becoming a kick-ass PHP ninja</a>&#8220;.</p>
<p>Here goes the slides:</p>
<div id="__ss_1448402" style="margin: 0pt auto; width: 425px; text-align: center;"><object width="425" height="355" data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=becomingaphpninja-090517141544-phpapp01&amp;stripped_title=becoming-a-php-ninja" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=becomingaphpninja-090517141544-phpapp01&amp;stripped_title=becoming-a-php-ninja" /><param name="allowfullscreen" value="true" /></object></div>
<p>All the other slides, pictures, and videos are available <a href="http://slides.phpxperts.net/">here</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/05/phpxperts-09-seminar-becoming-a-php-ninja/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Payment Library for Paypal, Authorize.net and 2Checkout</title>
		<link>http://phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-payment-gateway-library-for-paypal-authorizenet-and-2checkout</link>
		<comments>http://phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 20:03:27 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[2checkout]]></category>
		<category><![CDATA[authorize.net]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[exciting]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wrapper]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=207</guid>
		<description><![CDATA[If you are like me, whenever you need to work with a 3rd party API or a gateway, you&#8217;d first search in Google for a possible wrapper for it in PHP. When it comes to supporting payment gateways, you get bunch of libraries in the search results who are fundamentally different. Some of them are [...]]]></description>
			<content:encoded><![CDATA[<p>If you are like me, whenever you need to work with a 3rd party API or a gateway, you&#8217;d first search in Google for a possible wrapper for it in PHP. When it comes to supporting payment gateways, you get bunch of libraries in the search results who are fundamentally different. Some of them are old PHP 3/4 ones, some are new, some may need PEAR, etc.</p>
<p>As they were not required together in one single project, I used them whenever needed. But in one project, I needed them all. I thoughts it&#8217;s a chance and decided to stop using them and wrote my own ones where I can use the same methods for all the gateways.</p>
<p>So, here is an abstract PaymentGateway library which is being extended to be used for three popular payment gateways (<a href="http://www.paypal.com">Paypal</a>, <a href="http://www.authorize.net">Authorize.net</a>, and <a href="http://www.2checkout.com">2Checkout</a>) in order to provide you with a similar way of using them. Note that the libraries are for basic usage only and do not contain options for recurring payments. Without much babble, let&#8217;s see a few examples of how you can use them.</p>
<p><strong>Download</strong></p>
<blockquote class="left"><p>You can straight-away download the <strong><a href="http://phpfour.com/blog/downloads1" target="_blank">Payment library</a></strong> with all the libraries, examples, and readme.</p></blockquote>
<p><strong>Paypal</strong></p>
<p>In order to process payments using Paypal, you&#8217;ll need to follow these steps:</p>
<p>1. Send the required information to Paypal (snippet 1). Be sure to specify your Paypal email where you want to receive the funds, the success and failure pages, the IPN page, and the product information. The example has the test mode ON, which you will not need in real scenario.</p>
<p>2. Create a payment success page where Paypal will send your customer after payment.</p>
<p>3. Create a payment failure page where Paypal will send your customer after failed payment.</p>
<p>4. Create a IPN page where Paypal will send payment notification in the background. Make sure you use/remove the test mode in conjunction with step 1. (snippet 2)</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Include the paypal library</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Paypal.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create an instance of the paypal library</span><br />
<span style="color: #000088;">$myPaypal</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Paypal<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify your paypal email</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'business'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_PAYPAL_EMAIL'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the currency</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'currency_code'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'USD'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the url where paypal will send the user on success/failure</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'return'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://YOUR_HOST/payment/paypal_success.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cancel_return'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://YOUR_HOST/payment/paypal_failure.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the url where paypal will send the IPN</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'notify_url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://YOUR_HOST/payment/paypal_ipn.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the product information</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'item_name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'T-Shirt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'amount'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'9.99'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'item_number'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'001'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify any custom value</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'muri-khao'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Enable test mode if needed</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enableTestMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Let's start the train!</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submitPayment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><em>Snippet 1</em><br />
<span id="more-207"></span></p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Include the paypal library</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Paypal.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create an instance of the paypal library</span><br />
<span style="color: #000088;">$myPaypal</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Paypal<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Log the IPN results</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnLog</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Enable test mode if needed</span><br />
<span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enableTestMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Check validity and write down it</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validateIpn</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><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'payment_status'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Completed'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paypal.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SUCCESS'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paypal.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;FAILURE<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><em>Snippet 2</em></p>
<p><strong>Authorize.net</strong></p>
<p>In order to process payments using Authorize.net, you&#8217;ll need to follow these steps:</p>
<p>1. Send the required information to Authorize.net(snippet 3). Be sure to specify your Authorize.net login and secret key, the success/failure pages, the IPN page, and the product information. The example has the test mode ON, which you will not need in real scenario.</p>
<p>2. Create a payment success/failure page where Authorize.net will send your customer after payment.</p>
<p>3. Create a IPN page where Authorize.net will send payment notification in the background. Make sure you use/remove the test mode in conjunction with step 1. (snippet 4)</p>
<p>4. In order to set the secret key, log into your authorize.net merchant account. Go to &#8220;MD5 Hash&#8221; menu and set a secret word to desired values and use that in the &#8220;setUserInfo&#8221; function showed in the example.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Include the paypal library</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Authorize.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create an instance of the authorize.net library</span><br />
<span style="color: #000088;">$myAuthorize</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Authorize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify your authorize.net login and secret</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUserInfo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'YOUR_LOGIN'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_SECRET_KEY'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the url where authorize.net will send the user on success/failure</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Receipt_Link_URL'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://YOUR_HOST/payment/authorize_success.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the url where authorize.net will send the IPN</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Relay_URL'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://YOUR_HOST/payment/authorize_ipn.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the product information</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Description'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'T-Shirt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Amount'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'9.99'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Invoice_num'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Cust_ID'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'muri-khao'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Enable test mode if needed</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enableTestMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Let's start the train!</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submitPayment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><em>Snippet 3</em></p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Include the paypal library</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Authorize.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create an instance of the authorize.net library</span><br />
<span style="color: #000088;">$myAuthorize</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Authorize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Log the IPN results</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnLog</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify your authorize login and secret</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUserInfo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'YOUR_LOGIN'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_SECRET_KEY'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Enable test mode if needed</span><br />
<span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enableTestMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Check validity and write down it</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$myAuthorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validateIpn</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><br />
&nbsp; &nbsp; <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'authorize.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SUCCESS'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'authorize.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;FAILURE<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$myPaypal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><em>Snippet 4</em></p>
<p><strong>2Checkout</strong></p>
<p>In order to process payments using 2Checkout, you&#8217;ll need to follow these steps:</p>
<p>1. Send the required information to 2Checkout(snippet 5). Be sure to specify your 2Checkout vendor id, the return page, and the product information. Please note that 2Checkout does not send IPN in the background, so you will need to handle the payment data in the return page. The example has the test mode ON, which you will not need in real scenario.</p>
<p>2. Create a return page where 2Checkout will send your customer after payment. This is also where you will need to retrieve and use the payment data. Make sure you use/remove the test mode in conjunction with step 1. (snippet 6)</p>
<p>3. In order to set the secret key, log into your 2checkout.com account and go to &#8220;Look and Feel&#8221; section. At the bottom enter the &#8220;Secret Word&#8221; and use it in the IPN verification process as shown in the example.</p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Include the paypal library</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TwoCo.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create an instance of the authorize.net library</span><br />
<span style="color: #000088;">$my2CO</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwoCo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify your 2CheckOut vendor id</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sid'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_VENDOR_ID'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the order information</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cart_order_id'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'total'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'9.99'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify the url where authorize.net will send the IPN</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x_Receipt_Link_URL'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://YOUR_HOST/payment/twoco_ipn.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tco_currency'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'USD'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'muri-khao'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Enable test mode if needed</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enableTestMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Let's start the train!</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submitPayment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><em>Snippet 5</em></p>
<div class="codecolorer-container php blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Include the paypal library</span><br />
<span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TwoCo.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create an instance of the authorize.net library</span><br />
<span style="color: #000088;">$my2CO</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwoCo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Log the IPN results</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnLog</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Specify your authorize login and secret</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSecret</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'YOUR_SECRET_KEY'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Enable test mode if needed</span><br />
<span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enableTestMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Check validity and write down it</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validateIpn</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><br />
&nbsp; &nbsp; <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'2co.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SUCCESS'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'2co.txt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;FAILURE<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$my2CO</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ipnData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><em>Snippet 6</em></p>
<p>Hope this will help you integrate the payment gateways in an easy manner. If you have any questions, or find any bug, have a suggestion, feel free to post them as comment here. Btw, this library is released under the MIT license.</p>
<p><strong>Cheers!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/feed/</wfw:commentRss>
		<slash:comments>195</slash:comments>
		</item>
		<item>
		<title>Code Updates (HTTP class, Extended CodeIgniter Model, Cross-domain AJAX transport)</title>
		<link>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updated-http-class-extended-model-codeigniter-cross-domain-ajax-php</link>
		<comments>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:27:47 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Code Igniter]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[essential]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=186</guid>
		<description><![CDATA[Greetings to all the readers of my blog. Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings to all the readers of my blog.</p>
<p>Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to reassure you that the site is up and will be up as usual <img src='http://phpfour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Now, besides the slightly customized theme from Elegant Themes, I have put a few code updates. They are detailed below:</p>
<h3>Extended Model for CodeIgniter</h3>
<p>The <a href="http://www.phpfour.com/blog/2008/07/extended-model-for-codeigniter/">original version</a> of the Extended Model for CodeIgniter has been serving many people well. Although most users loved the nifty functions of the Model, many (including me) didn&#8217;t like the hacking of CI core to get this functionality. With the release of CodeIgniter 1.7, we can avoid that as we can now overload the Model class of CI like the other libraries. Follow this instruction:</p>
<p>1. Download the updated version from <a href="http://www.phpfour.com/blog/downloads/model-ci-2">here</a><br />
2. Put it in your application/libraries folder<br />
3. In your model files, use it this way: <strong>class Product extends MY_Model</strong><br />
4. Everything else is same just like the <a href="http://www.phpfour.com/blog/2008/07/extended-model-for-codeigniter/">original</a> one</p>
<h3>HTTP Class</h3>
<p>There is not much update in this class except for a few bug fixes (thanks to you guys). Also, I have included a license file in the package as many of you have asked. It&#8217;s released under the MIT license. The original post is <a href="http://www.phpfour.com/blog/2008/01/php-http-class/">here</a> for reference.</p>
<p>Download the update from <a href="http://www.phpfour.com/blog/downloads/http-class">here</a> and the API reference is <a href="http://www.phpfour.com/lib/http">here</a>.</p>
<h3>Cross-domain AJAX calls using PHP</h3>
<p>A minor bug fix in the code. Thanks to a few of you who pointed them out. Original post is <a href="http://www.phpfour.com/blog/2008/03/cross-domain-ajax-using-php/">here</a>. Download the update from <a href="http://www.phpfour.com/blog/downloads/transport">here</a>.</p>
<p>I have accelerated plans for the blog in 2009 so stay tuned for some worthy posts in this month. And do <a href="http://www.phpfour.com/blog/contact-me/">write to me</a> if you feel you have any questions/ideas/suggestions.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: phpfour.com @ 2012-02-04 12:16:12 -->
