<?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>Chris Monnat &#187; Programming</title>
	<atom:link href="http://www.christophermonnat.com/topics/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christophermonnat.com</link>
	<description>Programmer Extraordinaire</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:26:37 +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>CodeIgniter 2.0: First Look at Reactor</title>
		<link>http://www.christophermonnat.com/2011/02/codeigniter-2-0-first-look-at-reactor/</link>
		<comments>http://www.christophermonnat.com/2011/02/codeigniter-2-0-first-look-at-reactor/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 10:00:43 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=1222</guid>
		<description><![CDATA[If you are a PHP programmer then you have undoubtedly heard of the CodeIgniter (CI) framework at least once. First released in 2006, by EllisLab, CI has grown into the lightweight, fully functional and easy to use application framework of choice for developers across the web. A big milestone was reached two weeks ago with the release of version 2.0 and there has never been a better time to kick the tires and take it for a spin. Not Just Any Old Framework There are A LOT of open source PHP frameworks on the web today. Some of them are pretty nice tools and some of them aren&#8217;t. When evaluating a framework you need to look at several factors: community, documentation, features, support options and learning curve. Depending on your individual requirements you might have some additional criteria but I think that&#8217;s a decent baseline. Let&#8217;s see how CI stands up: Community Last look at the forums puts registered members at 190,000. Now that&#8217;s not necessarily active users, but that&#8217;s the number of developers who thought enough of the framework to get a forum account and join in on the conversation. EllisLab places a very high premium on their developer community and a number of the additions in 2.0 were added at their request. Documentation I have played around with a number of different PHP frameworks and you will be hard pressed to find a framework with better documentation than CI. The users guide is complete, easy to understand and up to date with all the latest bells and whistles. Any PHP developer with a basic understanding of object oriented programming (OOP) should be able to pick things up pretty easily. It&#8217;s worth noting that with the release of 2.0 some new sections of the users guide are still being fleshed out, but there is enough there to help get you started. Features This is the true question: &#8220;can the framework do what I need it to do?&#8221; This question really depends on what it is you need it to do. But CI has most of the standard framework features including model view controller (MVC) architecture, database abstraction, form validation, session handing, error handling, flexible/scalable architecture and libraries to handle tasks like uploading files, displaying event calendars, implementing carts for e-commerce sites and much more. If that&#8217;s not enough CI also lets you add any additional functionality you want/need by building your own custom library or extending core libraries that are already there. Support Options So you invest all this time and effort into learning a framework and building your business around it, what do you do if things suddenly stop working? While CI doesn&#8217;t offer any kind of commercial support, the community is full of folks on the forum waiting to lend a hand when necessary. There are also a number of bloggers out there who share their CI knowledge and can be tapped for help from time to time. The other thing worth mentioning here is that CI is backed by a successful commercial company in EllisLab (makers of ExpressionEngine CMS). So it&#8217;s a pretty safe bet that it&#8217;s not going anywhere anytime soon. Learning Curve We&#8217;re all on a timeline, so how long will it take to get up to speed? As I mentioned under documentation, CI is very well documented and has an active and vibrant community. With that said, anyone with a fair understanding of OOP should be able to pick things up pretty quickly. New to Version 2.0 So now that I have your attention, let&#8217;s take a look at the exciting new additions to CI in version 2.0: 2 Flavors: Core and Reactor As I mentioned above, CI is backed by a commercial company and is used by that company to develop their commercial products like ExpressionEngine and MojoMotor. That means that the development of the framework was limited to the needs of their products and the community got a little frustrated feeling that the development of the framework had stalled over time. In true EllisLab fashion they listened and in version 2.0 have released two different lines of development: Core and Reactor. You now have the option of working with CI Core (maintained by EllisLab) or CI Reactor (maintained by the community). Core is the version of CI that EllisLab uses and will only change when they need to make a change for their products. This version should be used by those looking for true stability and backward/forward compatibility. Reactor, on the other hand, is maintained by a team of community engineers who collectively monitor community needs/wants and incorporate new features on a more frequent basis. Since all changes made to Core will be incorporated into Reactor and that Reactor will be the more active of the two code bases it&#8217;s recommended that everyone use Reactor from this point forward. PHP5 Support A common point of contention with previous version of CI was that it wasn&#8217;t native PHP5 meaning the framework was backwards compatible with PHP4 and certain PHP5 features didn&#8217;t work or were not used. With the release of 2.0 this is no longer the case. PHP4 is no longer supported and you must be running PHP 5.1.6 or higher in order to use the framework. So feel free to start taking advantage of the OOP improvements of PHP5. Packages Distributing code for reuse or releasing complex libraries (for things like authentication) to the community has always been a somewhat clunky process. You would typically need to copy and paste certain files into certain places within your install in order for everything to work correctly. Config files in the config folder, libraries in their respective folder, etc. CI 2.0 does away with this issue by introducing a new way of collecting and distributing code called packages. Packages are similar in theory to modular development in that all the resources you are distributing are self contained. All packages will have their own libraries, models, helpers, config, and language files collected in their own directory which can then be placed into the application/third_party directory of the framework for use. This provides developers with a much easier way of sharing/releasing code for use by the community. This also opens the doors for more module based application development with CI. Drivers In previous versions of CI there hasn&#8217;t been an elegant way of creating classes that all share a common parent class and not their sibling classes (handy in certain situations). You can now accomplish this with a new type of library called a driver. Drivers allow you to create a parent class with unlimited child classes that have no access to their siblings (for things like DB abstraction). This is a nice architecture for providing the same type of functionality only using different tools or implementation methods. Along with being able to create your own drivers, CI 2.0 identifies three drivers in the documentation: Cacheing, Database and Javascript. Javascript Library Saving the best for last, the item I was most excited about with this release was the Javascript Library. CI 2.0 now gives you the ability to plug your favorite javascript framework into CI using drivers so you can incorporate javascript into your apps more easily. jQuery is being distributed with the framework by default but you can be sure there will be other drivers released shortly for other javascript frameworks. Upgrading So far this post has been mostly about what&#8217;s new and exciting in version 2.0 but there have also been some changes to the framework that might trip up seasoned developers and those of you looking to upgrade from an earlier version. First and foremost, all CI core classes are now prefixed with CI_. This means that all controllers, models, etc. now need to extend CI_Controller, CI_Model, etc. respectively. You will want to be sure to update your code accordingly when upgrading to version 2 (this already tripped me up once). Second, some old features and functionality have finally been removed for good like scaffolding, plugins and the validation library. Plugins never really gained much traction with CI developers and have been deprecated for some time now. The CI core CAPTCHA plugin has been converted to a helper and any plugins you have developed should be converted to helpers also. The validation library, which has been replaced for a while now by form_validation, is gone. So if you have been putting off updating your code to use the new form_validation library now is the time to do it. Finally, a number of improvements have been made to the encryption library which will prevent you from decrypting data that you have encrypted with a previous version. To deal with this, you will have to run an update on your data using the new encode_from_legacy() method which will decode your data and return a re-encrypted string using the new method for storage. Those are the big things to look out for when upgrading from a previous version. Visit the users guide for complete upgrading instructions. Is that it? This is just a quick list of my top 5 changes/additions to the framework that have been released in 2.0. There&#8217;s a lot more where that came from like new cache drivers with APC, memcached, and file-based support, new security library and over 50 bug fixes. You can see the complete list of what&#8217;s new in the change log. So what are you waiting for? Take CodeIgniter 2.0 for a spin today!]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2011/01/ci-logo.png"><img class="alignright size-full wp-image-1251" title="ci-logo" src="http://www.christophermonnat.com/wp-content/uploads/2011/01/ci-logo.png" alt="" width="183" height="50" /></a>If you are a PHP programmer then you have undoubtedly heard of the <a href="http://codeigniter.com">CodeIgniter</a> (CI) framework at least once. First released in 2006, by <a href="http://ellislab.com">EllisLab</a>, CI has grown into the lightweight, fully functional and easy to use application framework of choice for developers across the web. A big milestone was reached two weeks ago with the release of version 2.0 and there has never been a better time to kick the tires and take it for a spin.</p>
<p><span id="more-1222"></span></p>
<h2>Not Just Any Old Framework</h2>
<p>There are A LOT of open source PHP frameworks on the web today. Some of them are pretty nice tools and some of them aren&#8217;t. When evaluating a framework you need to look at several factors: community, documentation, features, support options and learning curve. Depending on your individual requirements you might have some additional criteria but I think that&#8217;s a decent baseline. Let&#8217;s see how CI stands up:</p>
<p><strong>Community</strong></p>
<p>Last look at the forums puts registered members at 190,000. Now that&#8217;s not necessarily active users, but that&#8217;s the number of developers who thought enough of the framework to get a forum account and join in on the conversation. EllisLab places a very high premium on their developer community and a number of the additions in 2.0 were added at their request.</p>
<p><strong>Documentation</strong></p>
<p>I have played around with a number of different PHP frameworks and you will be hard pressed to find a framework with better documentation than CI. The <a href="http://codeigniter.com/user_guide/index.html" target="_blank">users guide</a> is complete, easy to understand and up to date with all the latest bells and whistles. Any PHP developer with a basic understanding of object oriented programming (OOP) should be able to pick things up pretty easily.</p>
<p>It&#8217;s worth noting that with the release of 2.0 some new sections of the users guide are still being fleshed out, but there is enough there to help get you started.</p>
<p><strong>Features</strong></p>
<p>This is the true question: &#8220;can the framework do what I need it to do?&#8221; This question really depends on what it is you need it to do. But CI has most of the <a href="http://codeigniter.com/user_guide/overview/features.html" target="_blank">standard framework features</a> including model view controller (MVC) architecture, database abstraction, form validation, session handing, error handling, flexible/scalable architecture and libraries to handle tasks like uploading files, displaying event calendars, implementing carts for e-commerce sites and much more. If that&#8217;s not enough CI also lets you add any additional functionality you want/need by building your own custom library or extending core libraries that are already there.</p>
<p><strong>Support Options</strong></p>
<p>So you invest all this time and effort into learning a framework and building your business around it, what do you do if things suddenly stop working? While CI doesn&#8217;t offer any kind of commercial support, the community is full of folks on the <a href="http://codeigniter.com/forums/" target="_blank">forum</a> waiting to lend a hand when necessary. There are also a number of bloggers out there who share their CI knowledge and can be tapped for help from time to time.</p>
<p>The other thing worth mentioning here is that CI is backed by a successful commercial company in EllisLab (makers of <a href="http://www.expressionengine.com" target="_blank">ExpressionEngine CMS</a>). So it&#8217;s a pretty safe bet that it&#8217;s not going anywhere anytime soon.</p>
<p><strong>Learning Curve</strong></p>
<p>We&#8217;re all on a timeline, so how long will it take to get up to speed? As I mentioned under documentation, CI is very well documented and has an active and vibrant community. With that said, anyone with a fair understanding of OOP should be able to pick things up pretty quickly.</p>
<h2>New to Version 2.0</h2>
<p>So now that I have your attention, let&#8217;s take a look at the exciting new additions to CI in version 2.0:</p>
<h3>2 Flavors: Core and Reactor</h3>
<p>As I mentioned above, CI is backed by a commercial company and is used by that company to develop their commercial products like ExpressionEngine and MojoMotor. That means that the development of the framework was limited to the needs of their products and the community got a little frustrated feeling that the development of the framework had stalled over time. In true EllisLab fashion they listened and in version 2.0 have released two different lines of development: Core and Reactor.</p>
<p>You now have the option of working with CI Core (maintained by EllisLab) or CI Reactor (maintained by the community). Core is the version of CI that EllisLab uses and will only change when they need to make a change for their products. This version should be used by those looking for true stability and backward/forward compatibility. Reactor, on the other hand, is maintained by a team of community engineers who collectively monitor community needs/wants and incorporate new features on a more frequent basis.</p>
<p>Since all changes made to Core will be incorporated into Reactor and that Reactor will be the more active of the two code bases it&#8217;s recommended that everyone use Reactor from this point forward.</p>
<h3>PHP5 Support</h3>
<p>A common point of contention with previous version of CI was that it wasn&#8217;t native PHP5 meaning the framework was backwards compatible with PHP4 and certain PHP5 features didn&#8217;t work or were not used. With the release of 2.0 this is no longer the case. PHP4 is no longer supported and you must be running PHP 5.1.6 or higher in order to use the framework. So feel free to start taking advantage of the OOP improvements of PHP5.</p>
<h3>Packages</h3>
<p>Distributing code for reuse or releasing complex libraries (for things like authentication) to the community has always been a somewhat clunky process. You would typically need to copy and paste certain files into certain places within your install in order for everything to work correctly. Config files in the config folder, libraries in their respective folder, etc. CI 2.0 does away with this issue by introducing a new way of collecting and distributing code called packages.</p>
<p><a href="http://codeigniter.com/user_guide/libraries/loader.html" target="_blank">Packages</a> are similar in theory to modular development in that all the resources you are distributing are self contained. All packages will have their own libraries, models, helpers, config, and language files collected in their own directory which can then be placed into the application/third_party directory of the framework for use. This provides developers with a much easier way of sharing/releasing code for use by the community. This also opens the doors for more module based application development with CI.</p>
<h3>Drivers</h3>
<p>In previous versions of CI there hasn&#8217;t been an elegant way of creating classes that all share a common parent class and not their sibling classes (handy in certain situations). You can now accomplish this with a new type of library called a driver. <a href="http://codeigniter.com/user_guide/general/drivers.html" target="_blank">Drivers</a> allow you to create a parent class with unlimited child classes that have no access to their siblings (for things like DB abstraction). This is a nice architecture for providing the same type of functionality only using different tools or implementation methods.</p>
<p>Along with being able to create your own drivers, CI 2.0 identifies three drivers in the documentation: Cacheing, Database and Javascript.</p>
<h3>Javascript Library</h3>
<p>Saving the best for last, the item I was most excited about with this release was the <a href="http://codeigniter.com/user_guide/libraries/javascript.html" target="_blank">Javascript Library</a>. CI 2.0 now gives you the ability to plug your favorite javascript framework into CI using drivers so you can incorporate javascript into your apps more easily. <a href="http://jquery.com" target="_blank">jQuery</a> is being distributed with the framework by default but you can be sure there will be other drivers released shortly for other javascript frameworks.</p>
<h2>Upgrading</h2>
<p>So far this post has been mostly about what&#8217;s new and exciting in version 2.0 but there have also been some changes to the framework that might trip up seasoned developers and those of you looking to upgrade from an earlier version. First and foremost, all CI core classes are now prefixed with CI_. This means that all controllers, models, etc. now need to extend CI_Controller, CI_Model, etc. respectively. You will want to be sure to update your code accordingly when upgrading to version 2 (this already tripped me up once).</p>
<p>Second, some old features and functionality have finally been removed for good like scaffolding, plugins and the validation library. Plugins never really gained much traction with CI developers and have been deprecated for some time now. The CI core CAPTCHA plugin has been converted to a helper and any plugins you have developed should be converted to helpers also. The validation library, which has been replaced for a while now by form_validation, is gone. So if you have been putting off updating your code to use the new form_validation library now is the time to do it.</p>
<p>Finally, a number of improvements have been made to the encryption library which will prevent you from decrypting data that you have encrypted with a previous version. To deal with this, you will have to run an update on your data using the new encode_from_legacy() method which will decode your data and return a re-encrypted string using the new method for storage.</p>
<p>Those are the big things to look out for when upgrading from a previous version. Visit the users guide for <a href="http://codeigniter.com/user_guide/installation/upgrading.html" target="_blank">complete upgrading instructions</a>.</p>
<h2>Is that it?</h2>
<p>This is just a quick list of my top 5 changes/additions to the framework that have been released in 2.0. There&#8217;s a lot more where that came from like new cache drivers with APC, memcached, and file-based support, new security library and over 50 bug fixes. You can see the complete list of what&#8217;s new in the <a href="http://codeigniter.com/user_guide/changelog.html" target="_blank">change log</a>. So what are you waiting for? Take CodeIgniter 2.0 for a spin today!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2011/02/codeigniter-2-0-first-look-at-reactor/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Review: PHP5 Social Networking</title>
		<link>http://www.christophermonnat.com/2011/02/review-php5-social-networking/</link>
		<comments>http://www.christophermonnat.com/2011/02/review-php5-social-networking/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 01:30:58 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=1247</guid>
		<description><![CDATA[At this point in human history we are all pretty well versed in social networking. Our pets are even getting in on the whole social web experience. We&#8217;re all familiar with what social networks are and why we should, or should not, use them. But how does one go about building one from scratch? While the overall complexity of building a social networking site really depends on the requirements, the typical features for most networks (relationships, etc.) can get rather complex. Before you start pulling your hair out or reverse engineering Drupal, there is a new book called PHP5 Social Networking that might be just the thing to help you out. In this post I&#8217;m going to give you a glance at this new book published by Packt and tell you if it&#8217;s worth adding to your tech library. What&#8217;s it about? PHP5 Social Networking by Michael Peacock is a complete detail packed reference on how to build your own social network. Weighing in at over 400 pages this book isn&#8217;t a quick read but it has a wealth of information for those people looking for answers to common social network construction questions. Everything is covered from user profiles and groups to activity streams and events. You will even construct your own API. The author starts off deconstructing a handfull of popular social networks down to their most basic features and functions. He then puts together a list of the features they all have in common and that becomes the feature list of the network you will build throughout the book. From that point on the author walks  you step by step through the creation of your own PHP framework and social network for dinosaur owners (yeah, I said dinosaurs). Finally, the book wraps up with some sections on hosting and maintaining your site as well as marketing it to your users. Pros and Cons I could have really used this book a year or two ago when I first started building myScoutPath. Everything is here to get you well on your way to a fully functioning social network with all the bells and whistles. The author does a good job at walking the reader through each solution and what they can do to improve them further. The examples are also clear enough where you can take what you learn and implement it with whatever framework or architecture you choose. If they could improve anything I would say cut down on the code samples a little bit. Complete code libraries are printed throughout the book and I think it makes it unnecessarily big and potentially overwhelming to some. Maybe just provide excerpts from libraries within the book; users can view the complete source code later on if they wish anyway. I don&#8217;t recommend sitting down and reading this book cover to cover unless you&#8217;re in for a nap (as with any technical book). Seek out the sections that you&#8217;re curious about the most and dig in. There&#8217;s a little something for everybody.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2011/01/php5-social-networking.png"><img class="alignright size-full wp-image-1257" title="php5-social-networking" src="http://www.christophermonnat.com/wp-content/uploads/2011/01/php5-social-networking.png" alt="" width="114" height="140" /></a>At this point in human history we are all pretty well versed in social networking. <a href="http://www.mydogspace.com/" target="_blank">Our</a> <a href="http://www.mycatspace.com/" target="_blank">pets</a> are even getting in on the whole social web experience. We&#8217;re all familiar with what social networks are and why we should, or should not, use them. But how does one go about building one from scratch? While the overall complexity of building a social networking site really depends on the requirements, the typical features for most networks (relationships, etc.) can get rather complex. Before you start pulling your hair out or reverse engineering <a href="http://www.drupal.org">Drupal</a>, there is a new book called <a href="https://www.packtpub.com/php-5-social-networking/book" target="_blank">PHP5 Social Networking</a> that might be just the thing to help you out. In this post I&#8217;m going to give you a glance at this new book published by <a href="http://www.packtpub.com" target="_blank">Packt</a> and tell you if it&#8217;s worth adding to your tech library.</p>
<p><span id="more-1247"></span></p>
<h2>What&#8217;s it about?</h2>
<p>PHP5 Social Networking by Michael Peacock is a complete detail packed reference on how to build your own social network. Weighing in at over 400 pages this book isn&#8217;t a quick read but it has a wealth of information for those people looking for answers to common social network construction questions. Everything is covered from user profiles and groups to activity streams and events. You will even construct your own API.</p>
<p>The author starts off deconstructing a handfull of popular social networks down to their most basic features and functions. He then puts together a list of the features they all have in common and that becomes the feature list of the network you will build throughout the book. From that point on the author walks  you step by step through the creation of your own PHP framework and social network for dinosaur owners (yeah, I said dinosaurs). Finally, the book wraps up with some sections on hosting and maintaining your site as well as marketing it to your users.</p>
<h2>Pros and Cons</h2>
<p>I could have really used this book a year or two ago when I first started building myScoutPath. Everything is here to get you well on your way to a fully functioning social network with all the bells and whistles. The author does a good job at walking the reader through each solution and what they can do to improve them further. The examples are also clear enough where you can take what you learn and implement it with whatever framework or architecture you choose.</p>
<p>If they could improve anything I would say cut down on the code samples a little bit. Complete code libraries are printed throughout the book and I think it makes it unnecessarily big and potentially overwhelming to some. Maybe just provide excerpts from libraries within the book; users can view the complete source code later on if they wish anyway.</p>
<p>I don&#8217;t recommend sitting down and reading this book cover to cover unless you&#8217;re in for a nap (as with any technical book). Seek out the sections that you&#8217;re curious about the most and dig in. There&#8217;s a little something for everybody.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2011/02/review-php5-social-networking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter 2.0 Released</title>
		<link>http://www.christophermonnat.com/2011/01/codeigniter-2-0-released/</link>
		<comments>http://www.christophermonnat.com/2011/01/codeigniter-2-0-released/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 14:26:12 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=1250</guid>
		<description><![CDATA[The wait is over, CodeIgniter 2.0 has been released!! Apparently this happened last Friday and I simply didn&#8217;t notice until now. This release is exciting for 2 reasons, first it brings with it a shit load of new features and fixes and second it introduces CI Reactor which is a community driven branch of the framework. Theres a lot to digest and get excited about so check out the blog post for yourself and get coding!]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2011/01/ci-logo.png"><img class="alignright size-full wp-image-1251" title="ci-logo" src="http://www.christophermonnat.com/wp-content/uploads/2011/01/ci-logo.png" alt="" width="183" height="50" /></a>The wait is over, CodeIgniter 2.0 has been released!! Apparently this happened last Friday and I simply didn&#8217;t notice until now. This release is exciting for 2 reasons, first it brings with it a shit load of <a href="http://codeigniter.com/user_guide/changelog.html" target="_blank">new features and fixes</a> and second it introduces CI Reactor which is a community driven branch of the framework. Theres a lot to digest and get excited about so check out the <a href="http://codeigniter.com/news/codeigniter_2.0.0_released" target="_blank">blog post</a> for yourself and get coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2011/01/codeigniter-2-0-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Make Phone Calls with Code Using Twilio</title>
		<link>http://www.christophermonnat.com/2010/12/communicate-with-your-users-using-twilio/</link>
		<comments>http://www.christophermonnat.com/2010/12/communicate-with-your-users-using-twilio/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 10:00:53 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=1096</guid>
		<description><![CDATA[Web applications are better than old school applications that get installed on your hard drive because you can access them from anywhere using the web. They do however suffer from the same limited communication channel as typical software because they can only interact with users via the computer. Users provide input via the keyboard and the app provides output via the screen. Wouldn&#8217;t it be cool if we could take advantage of other communication channels like phone and text messages to communicate with our users? Well now we can with the help of Twilio. In this post I&#8217;ll walk you through building an application that can make phone calls and send text messages using the Twilio API. Background For those of you who don&#8217;t know, Twilio is a web service API that empowers programmers with the ability to make phone calls and send SMS text messages programmatically. I first came across the service a while back and have been keeping an eye on it ever since because I think it has a lot of potential uses in modern web applications. In the past, having your application make a phone call used to entail a lot of programming and hardware overhead ($$$). Twilio makes it as simple as one single API call (that doesn&#8217;t break the bank) and you&#8217;re done. In this post I&#8217;m going to be building a sample application to illustrate some of what Twilio is capable of. Have you ever used a website or other service that required you to confirm your phone number by receiving a call and then entering a code given to you over the phone? Well that&#8217;s what we&#8217;re going to build. The concept is that a user fills out a generic registration form on your site and includes their phone number. Upon submission we will leverage Twilio to call the user and recite a 4 digit confirmation code that they will then have to enter in step 2 of the registration process. Upon validating the entered code from step 2 we will either send the user a SMS text message confirming a successful activation or display an error. For the purposes of this example I am leveraging the CodeIgniter framework simply for the sake of development speed. The code that actually interacts with the API can easily be transplanted into any application and still work. When it comes to interacting with the API, Twilio has a number of client libraries to choose from. Our weapon of choice is PHP, so I will be using the PHP client library. To make things a little easier I&#8217;m providing two downloads, one is the complete source code with all the code included. The other is just the framework preconfigured with the necessary libraries and helpers. This way, if you want to follow along, we won&#8217;t have to waste a lot of time setting up and configuring CodeIgniter. Step 1 &#8211; Get a Twilio Account Before you can access the Twilio API you first need to create an account to get access information. You typically have to pay to use Twilios service, but they do provide a free trial that comes with $30.00 worth of credit which you can use for the purposes of this example. Visit https://www.twilio.com/try-twilio and fill out the provided form. After creating your account, and logging in for the first time, you will be presented with your account dashboard. Your account dashboard is a collection of all of your account information in one easy to understand and access place. This is where you will find your Account SID and Auth Token. These are the two values you will need in order to make API requests. The dashboard also shows your account balance along with a rough calculation as to how that dollar amount translates into API requests. Your developer sandbox information is also displayed here, however we won&#8217;t be doing anything with the sandbox in this example. The other thing you will need to do before continuing is to setup an outgoing called ID number within Twilio. For obvious reasons you can&#8217;t just go placing calls and sending text messages from any old number. You first need to enter and confirm a caller ID number within your account and then you can use that number when making API requests. Within your Twilio account click Phone Numbers from the sub nav. At the bottom of this screen if where you can manage your called ID numbers. Click the Add Caller ID button and enter your phone number. Twilio will call you and request you enter a confirmation code (similar to the app we are about to build). After entering the code you should be all set. OK, so now that you have your API access information and have setup your caller ID your ready to jump in and get coding. Step 2 &#8211; Setup If you have not done so already, download a copy of the source code (blank or complete) and unzip the archive onto your desktop. For our registration example you will need to create a database and update CodeIgniters database settings (/application/config/database.php) with the appropriate access information. Once you have created your database, use the following SQL statement to create the one table we will be using. Now that you have created your database and updated the code you can upload everything to your development environment. You will notice that if you bring up the application in a browser you will most likely get an error. That&#8217;s because we haven&#8217;t created our default controller yet, but that&#8217;s the next step. Step 3 &#8211; Create the Controller Now that we&#8217;re up and running with our code and database we can get to coding. First thing to do is create a new controller called register.php in /application/controllers. When a user first visits our application we want to display our registration form so let&#8217;s setup our controller to do that by default. The above code leverages CodeIgniters default controller function index() to automatically display our registration form when a user first visits our application. Now we need to create our registration form view file. Create a new folder in /application/views called register and a new file in that folder called index.php. This view file contains just a simple four field registration form the user will complete to begin the registration process. Save and upload your changes and when you visit the application in a browser you should see the following form displayed. But before we go much further be sure to update the class variables at the top of the controller with your Account SID, Auth Token and caller ID number. Please note, the caller ID number should start with a plus sign (+), include the country code and have no hyphens. Step 4 &#8211; Access the API We now have our controller and registration form. You may notice however that when you submit the registration form nothing happens. The form is looking for a controller function called confirm(). This function will begin our user registration process by validating the form input, generating the users confirmation code and contacting the Twilio API to call our user and recite the code. Let&#8217;s go ahead and create this function now in our controller. The majority of this code should be pretty self explanatory (for those familiar with CI) but let&#8217;s review just to be safe. The first 13 lines are all about validation. We are using CodeIgniters form_validation library to validate our form input and ensure we have valid data. If there are any errors we display the form again with error messages. On line 19 we create a random 4 digit number that we will use as our confirmation code. This is the code we will pass to Twilio to recite to our users and then test for in step 2 of our process. This will be stored in our database along with our other user data. Lines 21-31 handle the database insertion for our user record using CIs active record library. 33-38 are where we contact the Twilio API and make our request to call the user (I&#8217;ll review these lines in a moment). The remainder of the function displays step 2 of our registration form which is just a single field asking the user to enter their confirmation code. Before we forget let&#8217;s create this new view file called confirm.php in /application/views/registration. As I mentioned above, lines 33-38 are where we actually make our API request to Twilio. The first thing we do here is determine if we need to make the call or not by checking the $call variable passed to the function. I put this in here to avoid making additional API calls if the user enters a wrong confirmation code (this will make sense later on). Next we create a new instance of TwilioRestClient which is the PHP client library and pass it our Account SID and Auth Token for authentication. Using our new TwilioRestClient object, we make a request to the API using the request() function. This function takes 3 arguments: the path to the API method your calling, the type of request your making (POST, GET, etc.) and any data you are passing along to the API (as an array). Something to make note of here is the path to the API method we are passing. In a rather odd turn of events, each API call must include your Account SID. I find this rather odd and verbose but alas it is required. There are ways to make this easier to use within your code by making a minor modification to their library, but I chose to keep things just the way they provide for the purposes of our example. So we are calling the /Accounts/Calls API method and passing it a &#8220;From&#8221; phone number, &#8220;To&#8221; phone number and &#8220;Url&#8221; to handle the call. The &#8220;From&#8221; number is the phone number the call will be made from (your Twilio called ID number). The &#8220;To&#8221; number is the number Twilio will be calling. It&#8217;s worth noting that this number must inclue the country code and contain no hyphens. The code should probably include some sanitization to ensure this, but I kept it out for simplicity. Finally the URL to handle the call is where Twilio will look for instructions on what to do for this call. This is where we have to provide it with instructions using TwiML or Twilio Markup Language. Step 5 &#8211; TwiML There is an entire section of documentation dedicated to TwiML, so I don&#8217;t intend on spending a tremendous amount of time on it. Suffice it to say it is the XML format that Twilio expects when looking for instructions on what to do when placing a phone call. You have several options to choose from but all we care to do is place a call and read a script. Let&#8217;s go ahead and create a new function in our controller called handle_call() to generate the necessary TwiML. The above code basically creates the following XML document. The first thing we do here is find our user based on ID in the DB. Next we take their confirmation code and put spaces between the numbers. Without doing this Twilio will pronounce the number as a complete number instead of digit by digit which would be a bummer for our users. Finally we put it all together in a script and call the addSay() function adding a loop attribute of 2 to make sure Twilio repeats the message twice. If you were to visit this function in your browser (/registration/handle_call) you would hopefully see the XML I provided above as an example. Step 6 &#8211; Confirmation We now have the majority of our application in place. The only thing we&#8217;re missing is the processing code to handle step 2 of our registration process. Let&#8217;s create a new function in our controller called confirm_code() to handle the final bit of validation. The above code processes the confirmation code submission and checks to see if our user entered the correct code or not. If correct, we send the user a SMS text message using Twilio and display a view called account_activated.php. If incorrect, we simply display a view called account_error.php. Let&#8217;s create those two views now in /application/views/register. The code for sending the text message is very similar to the block we used to make the phone call above. This time we are requesting the /SMS/Messages API method to send a text message and passing along &#8220;From&#8221;, &#8220;To&#8221; and &#8220;Body&#8221; as parameters. Just like above &#8220;From&#8221; is the phone number we are sending from (our Twilio caller ID number), &#8220;To&#8221; is the number we are sending to and &#8220;Body&#8221; is the actual content of the text message. It&#8217;s worth mentioning that text messages don&#8217;t require any TwiML instructions, only phone calls. And there you have it. If you save and upload your changes you should now have a functioning example. Enter your phone number in the phone number field of the registration form (being sure to include the country code and no hyphens) and hit submit. You should shortly receive a phone call reciting your confirmation code. Enter that code in the confirmation code form and submit. You should then see the success message and receive a congratulatory text message. Debugging When I was first building this app I was not having much luck with placing phone calls. Twilio would call me but say there was a system error and then hang up (very frustrating). Come to find out that I had my site password protected and it couldn&#8217;t get to the handle_call() function for the TwiML instructions. The point of this story is I wouldn&#8217;t have been able to figure out what the problem was without the Twilio Debugger available through your Twilio account. The debugger, available when you log-in and click Debugger from the sub nav, is your first stop when trying to deal with Twilio issues. It should give you the information you need to determine what the problem is. There is also some documentation available to help you deal with common issues. And if all else fails you can contact support for additional assistance. Conclusion This is obviously not a complete and well polished application but it does illustrate some of what Twilio is capable of. Some possible enhancements to this code could include adding a country code drop down menu to the registration form so the user doesn&#8217;t have to enter it as part of their phone number, better phone number validation to ensure processing and maybe e-mail integration since we are collecting the users e-mail address. Feel free to experiment on your own and let me know how you make out by leaving a comment. I know this was a long post but thanks for sticking with me. To learn more about what Twilios capable of, be sure to visit their documentation and implementation gallery.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2010/11/twilio-logo.png"><img class="alignright size-full wp-image-1137" title="twilio-logo" src="http://www.christophermonnat.com/wp-content/uploads/2010/11/twilio-logo.png" alt="" width="130" height="130" /></a>Web applications are better than old school applications that get installed on your hard drive because you can access them from anywhere using the web. They do however suffer from the same limited communication channel as typical software because they can only interact with users via the computer. Users provide input via the keyboard and the app provides output via the screen. Wouldn&#8217;t it be cool if we could take advantage of other communication channels like phone and text messages to communicate with our users? Well now we can with the help of <a href="http://www.twilio.com" target="_blank">Twilio</a>. In this post I&#8217;ll walk you through building an application that can make phone calls and send text messages using the Twilio API.</p>
<p><span id="more-1096"></span></p>
<h2>Background</h2>
<p>For those of you who don&#8217;t know, Twilio is a web service API that empowers programmers with the ability to make phone calls and send SMS text messages programmatically. I first came across the service a while back and have been keeping an eye on it ever since because I think it has a lot of potential uses in modern web applications. In the past, having your application make a phone call used to entail a lot of programming and hardware overhead ($$$). Twilio makes it as simple as one single API call (that doesn&#8217;t break the bank) and you&#8217;re done.</p>
<p>In this post I&#8217;m going to be building a sample application to illustrate some of what Twilio is capable of. Have you ever used a website or other service that required you to confirm your phone number by receiving a call and then entering a code given to you over the phone? Well that&#8217;s what we&#8217;re going to build. The concept is that a user fills out a generic registration form on your site and includes their phone number. Upon submission we will leverage Twilio to call the user and recite a 4 digit confirmation code that they will then have to enter in step 2 of the registration process. Upon validating the entered code from step 2 we will either send the user a SMS text message confirming a successful activation or display an error.</p>
<p>For the purposes of this example I am leveraging the <a href="http://codeigniter.com" target="_blank">CodeIgniter framework</a> simply for the sake of development speed. The code that actually interacts with the API can easily be transplanted into any application and still work. When it comes to interacting with the API, Twilio has a number of <a href="http://www.twilio.com/docs/libraries/" target="_blank">client libraries to choose from</a>. Our weapon of choice is PHP, so I will be using the PHP client library.</p>
<p>To make things a little easier I&#8217;m providing two downloads, one is the <a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-complete.zip">complete source code</a> with all the code included. The other is <a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-blank.zip">just the framework</a> preconfigured with the necessary libraries and helpers. This way, if you want to follow along, we won&#8217;t have to waste a lot of time setting up and configuring CodeIgniter.</p>
<h2>Step 1 &#8211; Get a Twilio Account</h2>
<p>Before you can access the Twilio API you first need to create an account to get access information. You typically have to pay to use Twilios service, but they do provide a free trial that comes with $30.00 worth of credit which you can use for the purposes of this example.</p>
<p>Visit <a href="https://www.twilio.com/try-twilio" target="_blank">https://www.twilio.com/try-twilio</a> and fill out the provided form.</p>
<p><center><a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-signup.png"><img class="aligncenter size-full wp-image-1183" title="twilio-signup" src="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-signup.png" alt="" width="400" height="309" /></a></center>After creating your account, and logging in for the first time, you will be presented with your account dashboard.</p>
<p><a href="http://www.christophermonnat.com/wp-content/uploads/2010/11/twilio-dashboard.png"><img class="aligncenter size-full wp-image-1145" title="twilio-dashboard" src="http://www.christophermonnat.com/wp-content/uploads/2010/11/twilio-dashboard.png" alt="" width="595" height="615" /></a></p>
<p>Your account dashboard is a collection of all of your account information in one easy to understand and access place. This is where you will find your Account SID and Auth Token. These are the two values you will need in order to make API requests. The dashboard also shows your account balance along with a rough calculation as to how that dollar amount translates into API requests. Your developer sandbox information is also displayed here, however we won&#8217;t be doing anything with the sandbox in this example.</p>
<p>The other thing you will need to do before continuing is to setup an outgoing called ID number within Twilio. For obvious reasons you can&#8217;t just go placing calls and sending text messages from any old number. You first need to enter and confirm a caller ID number within your account and then you can use that number when making API requests.</p>
<p><center><a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-numbers.png"><img class="aligncenter size-full wp-image-1201" title="twilio-numbers" src="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-numbers.png" alt="" width="595" height="342" /></a></center>Within your Twilio account click Phone Numbers from the sub nav. At the bottom of this screen if where you can manage your called ID numbers. Click the Add Caller ID button and enter your phone number. Twilio will call you and request you enter a confirmation code (similar to the app we are about to build). After entering the code you should be all set.</p>
<p>OK, so now that you have your API access information and have setup your caller ID your ready to jump in and get coding.</p>
<h2>Step 2 &#8211; Setup</h2>
<p>If you have not done so already, download a copy of the source code (<a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-blank.zip">blank</a> or <a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-complete.zip">complete</a>) and unzip the archive onto your desktop. For our registration example you will need to create a database and update CodeIgniters database settings (/application/config/database.php) with the appropriate access information. Once you have created your database, use the following SQL statement to create the one table we will be using.</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL auto_increment,
`fname` varchar(50) NOT NULL,
`lname` varchar(50) NOT NULL,
`email` varchar(200) NOT NULL,
`phone` varchar(12) NOT NULL,
`confirm_code` varchar(4) default NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
</pre>
<p>Now that you have created your database and updated the code you can upload everything to your development environment. You will notice that if you bring up the application in a browser you will most likely get an error. That&#8217;s because we haven&#8217;t created our default controller yet, but that&#8217;s the next step.</p>
<h2>Step 3 &#8211; Create the Controller</h2>
<p>Now that we&#8217;re up and running with our code and database we can get to coding. First thing to do is create a new controller called <strong>register.php</strong> in /application/controllers. When a user first visits our application we want to display our registration form so let&#8217;s setup our controller to do that by default.</p>
<pre class="brush: php; title: ; notranslate">
class Register extends Controller
{
private $_account_sid = '';
private $_auth_token  = '';
private $_from_phone  = '';

public function __construct()
{
parent::__construct();

require_once(APPPATH . 'libraries/twilio.php');
}

// ------------------------------------------------------------------------

/**
 * Display app registration form.
 *
 * @access public
 * @return void
 */
public function index()
{
$temp_data = array(
'page_title' =&amp;amp;amp;gt; lang('application'),
'content_main' =&amp;amp;amp;gt; $this-&amp;amp;amp;gt;load-&amp;amp;amp;gt;view('register/index', 0, TRUE)
);

$this-&amp;amp;amp;gt;load-&amp;amp;amp;gt;view('_layouts/default', $temp_data);
}
}
</pre>
<p>The above code leverages CodeIgniters default controller function index() to automatically display our registration form when a user first visits our application. Now we need to create our registration form view file. Create a new folder in /application/views called <strong>register</strong> and a new file in that folder called <strong>index.php</strong>.</p>
<pre class="brush: php; title: ; notranslate">
&lt;h1&gt;&lt;?php echo lang('application'); ?&gt;&lt;/h1&gt;
&lt;?php echo display_form_error(validation_errors()); ?&gt;

&lt;?php echo form_open('register/confirm'); ?&gt;

&lt;p&gt;&lt;label for=&quot;fname&quot;&gt;First name: &lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;fname&quot; id=&quot;fname&quot; value=&quot;&lt;?php echo set_value('fname'); ?&gt;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;label for=&quot;lname&quot;&gt;Last name: &lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;lname&quot; id=&quot;lname&quot; value=&quot;&lt;?php echo set_value('lname'); ?&gt;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;label for=&quot;email&quot;&gt;Email address: &lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;label for=&quot;phone&quot;&gt;Phone number: &lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;phone&quot; id=&quot;phone&quot; maxlength=&quot;12&quot; value=&quot;&lt;?php echo set_value('phone'); ?&gt;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Register now&quot; /&gt;&lt;/p&gt;

&lt;?php echo form_close(); ?&gt;
</pre>
<p>This view file contains just a simple four field registration form the user will complete to begin the registration process. Save and upload your changes and when you visit the application in a browser you should see the following form displayed. But before we go much further be sure to update the class variables at the top of the controller with your Account SID, Auth Token and caller ID number. Please note, the caller ID number should start with a plus sign (+), include the country code and have no hyphens.</p>
<p><center><a href="http://www.christophermonnat.com/wp-content/uploads/2010/11/twilio-reg-form.png"><img class="aligncenter size-full wp-image-1161" title="twilio-reg-form" src="http://www.christophermonnat.com/wp-content/uploads/2010/11/twilio-reg-form.png" alt="" width="595" height="270" /></a></center></p>
<h2>Step 4 &#8211; Access the API</h2>
<p>We now have our controller and registration form. You may notice however that when you submit the registration form nothing happens. The form is looking for a controller function called confirm(). This function will begin our user registration process by validating the form input, generating the users confirmation code and contacting the Twilio API to call our user and recite the code. Let&#8217;s go ahead and create this function now in our controller.</p>
<pre class="brush: php; title: ; notranslate">
public function confirm($call = TRUE)
{
$this-&amp;amp;gt;load-&amp;amp;gt;library('form_validation');

$this-&amp;amp;gt;form_validation-&amp;amp;gt;set_error_delimiters('&amp;amp;lt;li&amp;amp;gt;', '&amp;amp;lt;/li&amp;amp;gt;');

$rules = array(
array('field' =&amp;amp;gt; 'fname', 'label' =&amp;amp;gt; 'first name', 'rules' =&amp;amp;gt; 'trim|required|htmlentities'),
array('field' =&amp;amp;gt; 'lname', 'label' =&amp;amp;gt; 'last name', 'rules' =&amp;amp;gt; 'trim|required|htmlentities'),
array('field' =&amp;amp;gt; 'email', 'label' =&amp;amp;gt; 'email address', 'rules' =&amp;amp;gt; 'trim|required|valid_email|htmlentities'),
array('field' =&amp;amp;gt; 'phone', 'label' =&amp;amp;gt; 'phone number', 'rules' =&amp;amp;gt; 'trim|required|htmlentities'),
);

$this-&amp;amp;gt;form_validation-&amp;amp;gt;set_rules($rules);

if($this-&amp;amp;gt;form_validation-&amp;amp;gt;run())
{
// generate random 4 digit confirmation code
$confirm_code = rand(1000,9999);

// add new user to DB
$user_data = array(
'fname' =&amp;amp;gt; $this-&amp;amp;gt;input-&amp;amp;gt;post('fname'),
'lname' =&amp;amp;gt; $this-&amp;amp;gt;input-&amp;amp;gt;post('lname'),
'email' =&amp;amp;gt; $this-&amp;amp;gt;input-&amp;amp;gt;post('email'),
'phone' =&amp;amp;gt; $this-&amp;amp;gt;input-&amp;amp;gt;post('phone'),
'confirm_code' =&amp;amp;gt; $confirm_code
);

$this-&amp;amp;gt;db-&amp;amp;gt;insert('users', $user_data);
$user_id = $this-&amp;amp;gt;db-&amp;amp;gt;insert_id();

if($call)
{
// make call request to Twilio
$twilio = new TwilioRestClient($this-&amp;amp;gt;_account_sid, $this-&amp;amp;gt;_auth_token);
$result = $twilio-&amp;amp;gt;request('2010-04-01/Accounts/' . $this-&amp;amp;gt;_account_sid . '/Calls', 'POST', array('From' =&amp;amp;gt; $this-&amp;amp;gt;_from_phone, 'To' =&amp;amp;gt; $this-&amp;amp;gt;input-&amp;amp;gt;post('phone'), 'Url' =&amp;amp;gt; site_url('register/handle_call/' . $user_id)));
}

// display confirmation form
$page_data = array(
'user_id' =&amp;amp;gt; $this-&amp;amp;gt;db-&amp;amp;gt;insert_id()
);

$temp_data = array(
'page_title' =&amp;amp;gt; lang('application'),
'content_main' =&amp;amp;gt; $this-&amp;amp;gt;load-&amp;amp;gt;view('register/confirm', $page_data, TRUE)
);

$this-&amp;amp;gt;load-&amp;amp;gt;view('_layouts/default', $temp_data);
}
else
{
// display form errors
$this-&amp;amp;gt;index();
}
}
</pre>
<p>The majority of this code should be pretty self explanatory (for those familiar with CI) but let&#8217;s review just to be safe. The first 13 lines are all about validation. We are using CodeIgniters form_validation library to validate our form input and ensure we have valid data. If there are any errors we display the form again with error messages. On line 19 we create a random 4 digit number that we will use as our confirmation code. This is the code we will pass to Twilio to recite to our users and then test for in step 2 of our process. This will be stored in our database along with our other user data. Lines 21-31 handle the database insertion for our user record using CIs active record library. 33-38 are where we contact the Twilio API and make our request to call the user (I&#8217;ll review these lines in a moment). The remainder of the function displays step 2 of our registration form which is just a single field asking the user to enter their confirmation code. Before we forget let&#8217;s create this new view file called <strong>confirm.php</strong> in /application/views/registration.</p>
<pre class="brush: php; title: ; notranslate">
&lt;h1&gt;&lt;?php echo lang('application'); ?&gt;&lt;/h1&gt;

&lt;h2&gt;Confirm Your Identity&lt;/h2&gt;

&lt;p&gt;You will receive a phone call shortly providing a 4 digit confirmation code.
Please enter that code below and click &lt;strong&gt;Confirm&lt;/strong&gt;.&lt;/p&gt;

&lt;?php echo display_form_error(validation_errors()); ?&gt;

&lt;?php echo form_open('register/confirm_code'); ?&gt;

&lt;input type=&quot;hidden&quot; name=&quot;user_id&quot; value=&quot;&lt;?php echo $user_id; ?&gt;&quot; /&gt;

&lt;p&gt;&lt;label for=&quot;confirm_code&quot;&gt;Confirmation code: &lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;confirm_code&quot; id=&quot;confirm_code&quot; maxlength=&quot;4&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Confirm&quot; /&gt;&lt;/p&gt;

&lt;?php echo form_close(); ?&gt;
</pre>
<p>As I mentioned above, lines 33-38 are where we actually make our API request to Twilio.</p>
<pre class="brush: php; title: ; notranslate">
if($call)
{
// make call request to Twilio
$twilio = new TwilioRestClient($this-&amp;amp;gt;_account_sid, $this-&amp;amp;gt;_auth_token);
$result = $twilio-&amp;amp;gt;request('2010-04-01/Accounts/' . $this-&amp;amp;gt;_account_sid . '/Calls', 'POST', array('From' =&amp;amp;gt; $this-&amp;amp;gt;_from_phone, 'To' =&amp;amp;gt; $this-&amp;amp;gt;input-&amp;amp;gt;post('phone'), 'Url' =&amp;amp;gt; site_url('register/handle_call/' . $user_id)));
}
</pre>
<p>The first thing we do here is determine if we need to make the call or not by checking the $call variable passed to the function. I put this in here to avoid making additional API calls if the user enters a wrong confirmation code (this will make sense later on). Next we create a new instance of TwilioRestClient which is the PHP client library and pass it our Account SID and Auth Token for authentication. Using our new TwilioRestClient object, we make a request to the API using the request() function. This function takes 3 arguments: the path to the API method your calling, the type of request your making (POST, GET, etc.) and any data you are passing along to the API (as an array).</p>
<p>Something to make note of here is the path to the API method we are passing. In a rather odd turn of events, each API call must include your Account SID. I find this rather odd and verbose but alas it is required. There are ways to make this easier to use within your code by making a minor modification to their library, but I chose to keep things just the way they provide for the purposes of our example.</p>
<p>So we are calling the <a href="http://www.twilio.com/docs/api/2010-04-01/rest/call" target="_blank">/Accounts/Calls API method</a> and passing it a &#8220;From&#8221; phone number, &#8220;To&#8221; phone number and &#8220;Url&#8221; to handle the call. The &#8220;From&#8221; number is the phone number the call will be made from (your Twilio called ID number). The &#8220;To&#8221; number is the number Twilio will be calling. It&#8217;s worth noting that this number must inclue the country code and contain no hyphens. The code should probably include some sanitization to ensure this, but I kept it out for simplicity. Finally the URL to handle the call is where Twilio will look for instructions on what to do for this call. This is where we have to provide it with instructions using TwiML or Twilio Markup Language.</p>
<h2>Step 5 &#8211; TwiML</h2>
<p>There is an <a href="http://www.twilio.com/docs/api/2010-04-01/twiml/" target="_blank">entire section of documentation</a> dedicated to TwiML, so I don&#8217;t intend on spending a tremendous amount of time on it. Suffice it to say it is the XML format that Twilio expects when looking for instructions on what to do when placing a phone call. You have several options to choose from but all we care to do is place a call and read a script. Let&#8217;s go ahead and create a new function in our controller called <strong>handle_call()</strong> to generate the necessary TwiML.</p>
<pre class="brush: php; title: ; notranslate">
public function handle_call($user_id = NULL)
{
if(!is_null($user_id))
{
$user = $this-&gt;db-&gt;get_where('users', array('id' =&gt; $user_id))-&gt;row();

// put spaces between code so Twilio will pronounce digits instead of the complete number
$confirm_code = '';
for($i=0; $i&lt;=3; ++$i)
{
$confirm_code .= $user-&gt;confirm_code[$i] . ' ';
}

$script = 'Hello your confirmation code is ' . $confirm_code . '.';
}
else
{
$script = 'Im sorry but your account could not be verified.';
}

$twilio = new Response();
$twilio-&gt;addSay($script, array('loop' =&gt; 2));
$twilio-&gt;Respond();
}
</pre>
<p>The above code basically creates the following XML document.</p>
<pre class="brush: xml; title: ; notranslate">
&amp;amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot; ?&amp;amp;gt;
&amp;amp;lt;Response&amp;amp;gt;
     &amp;amp;lt;Say loop=&amp;amp;quot;2&amp;amp;quot;&amp;amp;gt;Hello your confirmation code is XXXX.&amp;amp;lt;/Say&amp;amp;gt;
&amp;amp;lt;/Response&amp;amp;gt;
</pre>
<p>The first thing we do here is find our user based on ID in the DB. Next we take their confirmation code and put spaces between the numbers. Without doing this Twilio will pronounce the number as a complete number instead of digit by digit which would be a bummer for our users. Finally we put it all together in a script and call the addSay() function adding a loop attribute of 2 to make sure Twilio repeats the message twice. If you were to visit this function in your browser (/registration/handle_call) you would hopefully see the XML I provided above as an example.</p>
<h2>Step 6 &#8211; Confirmation</h2>
<p>We now have the majority of our application in place. The only thing we&#8217;re missing is the processing code to handle step 2 of our registration process. Let&#8217;s create a new function in our controller called confirm_code() to handle the final bit of validation.</p>
<pre class="brush: php; title: ; notranslate">
function confirm_code()
{
$this-&gt;load-&gt;library('form_validation');

$this-&gt;form_validation-&gt;set_error_delimiters('&lt;li&gt;', '&lt;/li&gt;');

$rules = array(
array('field' =&gt; 'confirm_code', 'label' =&gt; 'confirmation code', 'rules' =&gt; 'trim|numeric|max_length[4]|htmlentities'),
);

$this-&gt;form_validation-&gt;set_rules($rules);

if($this-&gt;form_validation-&gt;run())
{
$user = $this-&gt;db-&gt;get_where('users', array('id' =&gt; $this-&gt;input-&gt;post('user_id')))-&gt;row();

if($user-&gt;confirm_code == $this-&gt;input-&gt;post('confirm_code'))
{
$this-&gt;db-&gt;update('users', array('confirm_code' =&gt; NULL), array('id' =&gt; $user-&gt;id));

// make SMS request to Twilio
$twilio = new TwilioRestClient($this-&gt;_account_sid, $this-&gt;_auth_token);
$result = $twilio-&gt;request('2010-04-01/Accounts/' . $this-&gt;_account_sid . '/SMS/Messages', 'POST', array('From' =&gt; $this-&gt;_from_phone, 'To' =&gt; $user-&gt;phone, 'Body' =&gt; 'Hi ' . $user-&gt;fname . ', Thanks for activating your account.'));

$content_main = $this-&gt;load-&gt;view('register/account_activated', 0, TRUE);
}
else
{
$content_main = $this-&gt;load-&gt;view('register/account_error', 0, TRUE);
}

$temp_data = array(
'page_title' =&gt; lang('application'),
'content_main' =&gt; $content_main
);

$this-&gt;load-&gt;view('_layouts/default', $temp_data);
}
else
{
$this-&gt;confirm(FALSE);
}
}
</pre>
<p>The above code processes the confirmation code submission and checks to see if our user entered the correct code or not. If correct, we send the user a SMS text message using Twilio and display a view called <strong>account_activated.php</strong>. If incorrect, we simply display a view called <strong>account_error.php</strong>. Let&#8217;s create those two views now in /application/views/register.</p>
<pre class="brush: php; title: ; notranslate">
&lt;h1&gt;&lt;?php echo lang('application'); ?&gt;&lt;/h1&gt;

&lt;p&gt;Your account has been activated.&lt;/p&gt;
</pre>
<pre class="brush: php; title: ; notranslate">
&lt;h1&gt;&lt;?php echo lang('application'); ?&gt;&lt;/h1&gt;

&lt;p&gt;Your account could not be verified at this time.&lt;/p&gt;
</pre>
<p>The code for sending the text message is very similar to the block we used to make the phone call above.</p>
<pre class="brush: php; title: ; notranslate">
$twilio = new TwilioRestClient($this-&gt;_account_sid, $this-&gt;_auth_token);
$result = $twilio-&gt;request('2010-04-01/Accounts/' . $this-&gt;_account_sid . '/SMS/Messages', 'POST', array('From' =&gt; $this-&gt;_from_phone, 'To' =&gt; $user-&gt;phone, 'Body' =&gt; 'Hi ' . $user-&gt;fname . ', Thanks for activating your account.'));
</pre>
<p>This time we are requesting the <a href="http://www.twilio.com/docs/api/2010-04-01/rest/sms" target="_blank">/SMS/Messages API method</a> to send a text message and passing along &#8220;From&#8221;, &#8220;To&#8221; and &#8220;Body&#8221; as parameters. Just like above &#8220;From&#8221; is the phone number we are sending from (our Twilio caller ID number), &#8220;To&#8221; is the number we are sending to and &#8220;Body&#8221; is the actual content of the text message. It&#8217;s worth mentioning that text messages don&#8217;t require any TwiML instructions, only phone calls.</p>
<p>And there you have it. If you save and upload your changes you should now have a functioning example. Enter your phone number in the phone number field of the registration form (being sure to include the country code and no hyphens) and hit submit. You should shortly receive a phone call reciting your confirmation code. Enter that code in the confirmation code form and submit. You should then see the success message and receive a congratulatory text message.</p>
<h2>Debugging</h2>
<p>When I was first building this app I was not having much luck with placing phone calls. Twilio would call me but say there was a system error and then hang up (very frustrating). Come to find out that I had my site password protected and it couldn&#8217;t get to the handle_call() function for the TwiML instructions. The point of this story is I wouldn&#8217;t have been able to figure out what the problem was without the Twilio Debugger available through your Twilio account.</p>
<p><center><a href="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-debugger.png"><img class="aligncenter size-full wp-image-1198" title="twilio-debugger" src="http://www.christophermonnat.com/wp-content/uploads/2010/12/twilio-debugger.png" alt="" width="595" height="293" /></a></center>The debugger, available when you log-in and click Debugger from the sub nav, is your first stop when trying to deal with Twilio issues. It should give you the information you need to determine what the problem is. There is also <a href="http://www.twilio.com/docs/errors/" target="_blank">some documentation</a> available to help you deal with common issues. And if all else fails you can <a href="http://getsatisfaction.com/twilio/" target="_blank">contact support</a> for additional assistance.</p>
<h2>Conclusion</h2>
<p>This is obviously not a complete and well polished application but it does illustrate some of what Twilio is capable of. Some possible enhancements to this code could include adding a country code drop down menu to the registration form so the user doesn&#8217;t have to enter it as part of their phone number, better phone number validation to ensure processing and maybe e-mail integration since we are collecting the users e-mail address. Feel free to experiment on your own and let me know how you make out by leaving a comment.</p>
<p>I know this was a long post but thanks for sticking with me. To learn more about what Twilios capable of, be sure to visit their <a href="http://www.twilio.com/docs/index" target="_blank">documentation</a> and <a href="http://www.twilio.com/gallery" target="_blank">implementation gallery</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2010/12/communicate-with-your-users-using-twilio/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Speedy Subscriptions Using Spreedly (Part 4) &#8211; Checking for Updates</title>
		<link>http://www.christophermonnat.com/2010/08/speedy-subscriptions-using-spreedly-part-4-checking-for-updates/</link>
		<comments>http://www.christophermonnat.com/2010/08/speedy-subscriptions-using-spreedly-part-4-checking-for-updates/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 10:00:55 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=1009</guid>
		<description><![CDATA[OK let&#8217;s recap. So far in this guide I&#8217;ve covered: creating your Spreedly account, setting up your subscription plans and (most recently) linking your applications sign-up process to your Spreedly account. The elephant in the room at this point is managing updates and allowing Spreedly to notify our application when users make modifications to their subscription/billing settings or when something goes wrong: like when a credit card expires or a transaction can&#8217;t be processed. In this final post I will review how to open the lines of communication between your Spreedly account (a.k.a. your billing system) and your application. Why is this important? Some of you may be asking yourselves &#8220;what is Chris talking about? I&#8217;ve linked up my sign-up form so I&#8217;m done, right?&#8221; Unfortunately no, your not quite finished. The thing to keep in mind, when working with any kind of third party billing service, is that we&#8217;re talking about 2 separate and distinct systems. Your application is not aware of any changes/updates made in the billing system and vice verse.  This is a problem because if a users credit card expires in your billing system you need some way of notifying your application so you can suspend access. Or if your customer cancels their account in your application you need to be sure to update your billing system so they don&#8217;t continue to get charged. This is the same concept when working with PayPal or any other 3rd party payment processor where the transaction takes place on their servers. We need a method for identifying accounts that have changed recently in our billing system so we can make any necessary updates in our application. Listening for Changes Spreedly is not shy about telling you when your customer data changes. In fact, when any of your subscribers change, Spreedly will POST a comma separated list of subscriber id&#8217;s (your customer id&#8217;s) to a URL which you specify. While tooling around your Spreedly accounts general settings you may have noticed a group of fields that start with &#8220;Subscribers Changed Notification URL&#8221;. This field is where you place the URL that Spreedly should use when POSTing changed accounts back to your application. This page can be part of your application or just a script that has access to  your database, but it needs to be there so that Spreedly has someone to talk to. When any of your subscribers change within Spreedly, the application will send a POST request to an address you specify in your settings containing a comma separated list of IDs. These are the customer IDs of those subscribers who have changed. So this is Spreedlys way of telling you that account 2, 4, 6 and 8 have changed and you may want to check them out and update your DB accordingly. As far as the necessary code, basically all we&#8217;re talking about is a method of a new or existing controller (using CodeIgniter) looking for the &#8220;subscriber_ids&#8221; POST variable and processing appropriately: Pretty easy huh? Why did this take so long? This series set a new record for how long it&#8217;s taken me to wrap up a post series and I apologize for that. The reason though is because I&#8217;ve been taking a good long look at all the payment services out there (they&#8217;re popping up all over the place) and have determined that there are others I like better than Spreedly. So as I started to change my mind and focus I spent less time with this service and as a result was unable to share my knowledge as I had planned. Currently Sign-Up-Sheet.com uses Chargify which won me over shortly after I started this series. However, I have since found another app that I like better called OpenGateway. The details as to why one is better than the other is for another post, but that&#8217;s what happened here. I got sidetracked by other options and simply was unable to regain my focus. Stay tuned for additional information on these payment options and let me know if you would like to see another series possibly on OpenGateway (which coincidentally happens to be built on CI) in the comments. That&#8217;s all folks And that does it for the Spreedly guide. My apologies for taking so long to complete but things got away from me a bit and one thing lead to another. If you think there is something I didn&#8217;t cover or have any additional questions please let me know in the comments.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif"><img class="alignright size-full wp-image-776" title="spreedly-logo" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif" alt="" width="160" height="90" /></a>OK let&#8217;s recap. So far in this guide I&#8217;ve covered: <a href="http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-1-service-overview-introduction/">creating your Spreedly account</a>, <a href="http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-2-account-configuration/">setting up your subscription plans</a> and (most recently) <a href="http://www.christophermonnat.com/2010/04/speedy-subscriptions-using-spreedly-part-3-the-sign-up-process/">linking your applications sign-up process to your Spreedly account</a>. The elephant in the room at this point is managing updates and allowing Spreedly to notify our application when users make modifications to their subscription/billing settings or when something goes wrong: like when a credit card expires or a transaction can&#8217;t be processed. In this final post I will review how to open the lines of communication between your Spreedly account (a.k.a. your billing system) and your application.<br />
<span id="more-1009"></span></p>
<h2>Why is this important?</h2>
<p>Some of you may be asking yourselves &#8220;what is Chris talking about? I&#8217;ve linked up my sign-up form so I&#8217;m done, right?&#8221; Unfortunately no, your not quite finished. The thing to keep in mind, when working with any kind of third party billing service, is that we&#8217;re talking about 2 separate and distinct systems. Your application is not aware of any changes/updates made in the billing system and vice verse.  This is a problem because if a users credit card expires in your billing system you need some way of notifying your application so you can suspend access. Or if your customer cancels their account in your application you need to be sure to update your billing system so they don&#8217;t continue to get charged.</p>
<p>This is the same concept when working with PayPal or any other 3rd party payment processor where the transaction takes place on their servers. We need a method for identifying accounts that have changed recently in our billing system so we can make any necessary updates in our application.</p>
<h2>Listening for Changes</h2>
<p>Spreedly is not shy about telling you when your customer data changes. In fact, when any of your subscribers change, Spreedly will POST  a comma separated list of subscriber id&#8217;s (your customer id&#8217;s) to a URL which you specify. While tooling around your Spreedly accounts general settings you may have noticed a group of fields that start with &#8220;Subscribers Changed Notification URL&#8221;. This field is where you place the URL that Spreedly should use when POSTing changed accounts back to your application. This page can be part of your application or just a script that has access to  your database, but it needs to be there so that Spreedly has someone to talk to.</p>
<p>When any of your subscribers change within Spreedly, the application will send a POST request to an address you specify in your settings containing a comma separated list of IDs. These are the customer IDs of those subscribers who have changed. So this is Spreedlys way of telling you that account 2, 4, 6 and 8 have changed and you may want to check them out and update your DB accordingly.</p>
<p>As far as the necessary code, basically all we&#8217;re talking about is a method of a new or existing controller (using CodeIgniter) looking for the &#8220;subscriber_ids&#8221; POST variable and processing appropriately:</p>
<pre class="brush: php; title: ; notranslate">
public function update_customers
{
$ids = explode(',', $this-&gt;input-&gt;post('subscriber_ids'));

foreach($ids as $id)
{
// get users data from Spreedly

// update your DB with new data
}
}
</pre>
<p>Pretty easy huh?</p>
<h2>Why did this take so long?</h2>
<p>This series set a new record for how long it&#8217;s taken me to wrap up a post series and I apologize for that. The reason though is because I&#8217;ve been taking a good long look at all the payment services out there (they&#8217;re popping up all over the place) and have determined that there are others I like better than Spreedly. So as I started to change my mind and focus I spent less time with this service and as a result was unable to share my knowledge as I had planned. </p>
<p>Currently <a href="http://sign-up-sheet.com">Sign-Up-Sheet.com</a> uses <a href="http://chargify.com">Chargify </a>which won me over shortly after I started this series. However, I have since found another app that I like better called <a href="http://opengateway.net">OpenGateway</a>. The details as to why one is better than the other is for another post, but that&#8217;s what happened here. I got sidetracked by other options and simply was unable to regain my focus. Stay tuned for additional information on these payment options and let me know if you would like to see another series possibly on OpenGateway (which coincidentally happens to be built on CI) in the comments.</p>
<h2>That&#8217;s all folks</h2>
<p>And that does it for the Spreedly guide. My apologies for taking so long to complete but things got away from me a bit and one thing lead to another. If you think there is something I didn&#8217;t cover or have any additional questions please let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2010/08/speedy-subscriptions-using-spreedly-part-4-checking-for-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speedy Subscriptions Using Spreedly (Part 3) &#8211; The Sign-up Process</title>
		<link>http://www.christophermonnat.com/2010/04/speedy-subscriptions-using-spreedly-part-3-the-sign-up-process/</link>
		<comments>http://www.christophermonnat.com/2010/04/speedy-subscriptions-using-spreedly-part-3-the-sign-up-process/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 10:00:47 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=973</guid>
		<description><![CDATA[Picking up right where I left off, in this post I will review integrating Spreedly with your programs sign-up process. As is the case with most services like this, including PayPal, the quickest way to incorporate Spreedly involves redirecting the user to their website and allowing the financial transaction to take place on their servers. The user is then redirected back to your website once the transaction has been completed. This is the quickest and easiest method available and is the one I will be reviewing. Quick Disclaimer Spreedly has a full featured API which provides people with programming experience a greater amount of integration flexibility, you just need to be conscience of the security liabilities involved. Links to 3rd party libraries and documentation can be found on the Spreedly website. To save on time and get this series wrapped up I will not be reviewing the API. Your Sign-up Process Before we can get to the Spreedly side of things we first need to define how our sign-up process is going to work. It is in our best interests, as the business owners, to make our sing-up process as quick and simple as possible so that more people will purchase accounts. Smashing Magazine published a post or two on sign-up form design a while back and I recommend you refer to those poses for further information on designing your process. The one thing I will say, as it pertains to process, is to keep your sign-up form short and sweet. We will be redirecting users to our Spreedly accounts for the actual financial transaction so don&#8217;t worry about collecting any of that data (address, CC info, etc.) on your form. Just collect the items that are vitally necessary to get the user setup and worry about the non-essentials after they log-in for the first time. Prerequisites As I mentioned above, we don&#8217;t need to worry about collecting any financial information on our website because all the financial transaction stuff will be handled by Spreedly. However, there is one bit of data that we need to keep track of in order to redirect our users over to Spreedly and that is the subscription plan ID. The way I have chosen to handle this is by creating a table in my applications database to hold a copy of my subscription plans and each plan will include their Spreedly ID. Come to find out I needed to create this table anyway to track the limits of each subscription plan and hold my users to the limits of the account they purchased. So in reality I simply added an additional column to this table to hold the Spreedly ID. Now you can chose to handle this any way that works for you and your application, but the bottom line is you simply need to be able to keep track of the subscription plans you have setup in Spreedly and the unique ID that has been assigned to them. Constructing the Subscribe Link So now that we have our subscription process down and have defined a place to keep track of our subscription plans and their IDs on the application side we can start looking at how exactly we will be linking to Spreedly. Spreedly makes it somewhat difficult to find your subscription plan ID so you have to go looking for it. When you are logged into your account, click Plans to view your subscription plans and click the name to edit it. The edit screen, which is shown above, allows you to make changes to your subscription plan. If you look at the URL of this page you will be able to find the ID of your subscription plan. It&#8217;s the number displayed between &#8220;subscription_plans&#8221; and &#8220;edit&#8221;. That&#8217;s the number you will need to keep track of on your application side. You should also take  a look at their documentation links in the box on the right side of the page which also reviews linking to subscription plans from your application. OK, so now that we have our subscription plan IDs we need to determine what the URL is going to look like. https://spreedly.com/signupsheet/subscribers/84736/subscribe/1019/screen-name-for-84736 The URL displayed above is a sample URL for the basic subscription plan.  Let&#8217;s take a look at this URL piece by piece to figure out what we need to modify: https:// &#8211; very important for security purposes. Since we are working with credit cards plain old http is forbidden. spreedly.com &#8211; as I&#8217;ve already mentioned, all the financial stuff is happening on the Spreedly servers and this is the proof. signupsheet &#8211; this is your unique account short site name. This can be modified on the Site Details screen under Configuration. subscribers/84736 - the number 84736 is the ID of the user or account in OUR system. So this number if the first thing we will customize. I recommend setting it to the unique identifier you use in your application to identify your accounts or users. Whatever is the root account level entity within your application. Be sure not to omit the &#8220;subscribers/&#8221; either, this identifies the ID your passing to Spreedly. 1019 &#8211; this is the subscription plan ID. This is the next thing we will customize depending on the subscription plan our user is purchasing. screen-name-for-84736 &#8211; this is a unique user/account name that we provide Spreedly. This is the last thing we will customize. Set this to whatever you wish, perhaps some combination of account name and ID. Whatever will make it easy for you to identify the account within Spreedly by name instead of ID. So that&#8217;s it. All URLs will be the same except for the 4 pieces identified above (in red): your short site name, an account/user ID from your system, the subscription plan ID and a user/account screen name. By customizing those segments you should now be able to successfully redirect your users to Spreedly for credit card processing. Passing Additional Data It&#8217;s also worth mentioning that you can pass additional data to your Spreedly subscription pages like the subscribers name and e-mail address. If you are already collecting this data on your applications sign-up form it would be helpful if these fields were already filled in on the subscription page. You can easily pass this data along to Spreedly by adding some GET variables onto the URL we constructed above: email=someone@someplace.com first_name=someone last_name=special If we use the above GET variables to pass additional information to our subscription forms, then our final Spreedly URL is going to look something like this: https://spreedly.com/signupsheet/subscribers/84736/subscribe/1019/screen-name-for-84736?email=someone@someplace.com&#38;first_name=someone&#38;last_name=special That&#8217;s all there is to it. Once the user inputs their credit card information they will be redirected to the URL which you specified in the subscription plan settings. You can also modify this on the fly by providing an additional GET variable to your URL: return_url. Using that variable you can dynamically redirect the user wherever you specify upon successfully completing the payment process. This comes in handy if you need to pass any kind of dynamic information along with your user when they are redirected back to your site. What&#8217;s Next? If you followed along you should now be up and running with using Spreedly to manage your applications payment processing. You may however notice one thing is missing&#8230; we have no way of knowing whether the payment was processed successfully or not. The user simply gets redirected where we say and that&#8217;s it. We also have no way of knowing when their subscription expires (unless we track that ourselves). In the next post I will look at how we open up the lines of communication between Spreedly and our applications so that we know more about whose paying and whose not.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif"><img class="alignright size-full wp-image-776" title="spreedly-logo" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif" alt="" width="160" height="90" /></a>Picking up right where I left off, in this post I will review integrating Spreedly with your programs sign-up process. As is the case with most services like this, including PayPal, the quickest way to incorporate Spreedly involves redirecting the user to their website and allowing the financial transaction to take place on their servers. The user is then redirected back to your website once the transaction has been completed. This is the quickest and easiest method available and is the one I will be reviewing.<br />
<span id="more-973"></span></p>
<h2>Quick Disclaimer</h2>
<p>Spreedly has a full featured API which provides people with programming experience a greater amount of integration flexibility, you just need to be conscience of the security liabilities involved. Links to 3rd party libraries and documentation can be found on the <a href="http://spreedly.com/info/integration/">Spreedly website</a>. To save on time and get this series wrapped up I will not be reviewing the API.</p>
<h2>Your Sign-up Process</h2>
<p>Before we can get to the Spreedly side of things we first need to define how our sign-up process is going to work. It is in our best interests, as the business owners, to make our sing-up process as quick and simple as possible so that more people will purchase accounts. Smashing Magazine published <a href="http://www.smashingmagazine.com/2008/07/04/web-form-design-patterns-sign-up-forms/">a post</a> or <a href="http://www.smashingmagazine.com/2008/07/08/web-form-design-patterns-sign-up-forms-part-2/">two</a> on sign-up form design a while back and I recommend you refer to those poses for further information on designing your process.</p>
<p>The one thing I will say, as it pertains to process, is to keep your sign-up form short and sweet. We will be redirecting users to our Spreedly accounts for the actual financial transaction so don&#8217;t worry about collecting any of that data (address, CC info, etc.) on your form. Just collect the items that are vitally necessary to get the user setup and worry about the non-essentials after they log-in for the first time.</p>
<h2>Prerequisites</h2>
<p>As I mentioned above, we don&#8217;t need to worry about collecting any financial information on our website because all the financial transaction stuff will be handled by Spreedly. However, there is one bit of data that we need to keep track of in order to redirect our users over to Spreedly and that is the subscription plan ID. The way I have chosen to handle this is by creating a table in my applications database to hold a copy of my subscription plans and each plan will include their Spreedly ID. Come to find out I needed to create this table anyway to track the limits of each subscription plan and hold my users to the limits of the account they purchased. So in reality I simply added an additional column to this table to hold the Spreedly ID.</p>
<p>Now you can chose to handle this any way that works for you and your application, but the bottom line is you simply need to be able to keep track of the subscription plans you have setup in Spreedly and the unique ID that has been assigned to them.</p>
<h2>Constructing the Subscribe Link</h2>
<p>So now that we have our subscription process down and have defined a place to keep track of our subscription plans and their IDs on the application side we can start looking at how exactly we will be linking to Spreedly.</p>
<p><a href="http://www.christophermonnat.com/wp-content/uploads/2010/04/spreedly-sub-plans.png"><img class="aligncenter size-full wp-image-980" title="spreedly-sub-plans" src="http://www.christophermonnat.com/wp-content/uploads/2010/04/spreedly-sub-plans.png" alt="" width="595" height="348" /></a></p>
<p>Spreedly makes it somewhat difficult to find your subscription plan ID so you have to go looking for it. When you are logged into your account, click <strong>Plans</strong> to view your subscription plans and click the name to edit it. The edit screen, which is shown above, allows you to make changes to your subscription plan. If you look at the URL of this page you will be able to find the ID of your subscription plan. It&#8217;s the number displayed between &#8220;subscription_plans&#8221; and &#8220;edit&#8221;. That&#8217;s the number you will need to keep track of on your application side. You should also take  a look at <a href="https://spreedly.com/manual/integration-guide/expose-a-subscribe-link/">their documentation</a> links in the box on the right side of the page which also reviews linking to subscription plans from your application.</p>
<p>OK, so now that we have our subscription plan IDs we need to determine what the URL is going to look like.</p>
<p><strong>https://spreedly.com/signupsheet/subscribers/84736/subscribe/1019/screen-name-for-84736</strong></p>
<p>The URL displayed above is a sample URL for the basic subscription plan.  Let&#8217;s take a look at this URL piece by piece to figure out what we need to modify:</p>
<ul>
<li><strong>https://</strong> &#8211; very important for security purposes. Since we are working with credit cards plain old http is forbidden.</li>
<li><strong>spreedly.com</strong> &#8211; as I&#8217;ve already mentioned, all the financial stuff is happening on the Spreedly servers and this is the proof.</li>
<li><span style="color: #993300;"><strong>signupsheet</strong></span> &#8211; this is your unique account short site name. This can be modified on the Site Details screen under Configuration.</li>
<li><strong>subscribers/<span style="color: #993300;">84736</span> </strong>- the number 84736 is the ID of the user or account in OUR system. So this number if the first thing we will customize. I recommend setting it to the unique identifier you use in your application to identify your accounts or users. Whatever is the root account level entity within your application. Be sure not to omit the &#8220;subscribers/&#8221; either, this identifies the ID your passing to Spreedly.</li>
<li><strong><span style="color: #993300;">1019</span></strong> &#8211; this is the subscription plan ID. This is the next thing we will customize depending on the subscription plan our user is purchasing.</li>
<li><span style="color: #993300;"><strong>screen-name-for-84736</strong></span> &#8211; this is a unique user/account name that we provide Spreedly. This is the last thing we will customize. Set this to whatever you wish, perhaps some combination of account name and ID. Whatever will make it easy for you to identify the account within Spreedly by name instead of ID.</li>
</ul>
<p>So that&#8217;s it. All URLs will be the same except for the 4 pieces identified above (in red): your short site name, an account/user ID from your system, the subscription plan ID and a user/account screen name. By customizing those segments you should now be able to successfully redirect your users to Spreedly for credit card processing.</p>
<h2>Passing Additional Data</h2>
<p>It&#8217;s also worth mentioning that you can pass additional data to your Spreedly subscription pages like the subscribers name and e-mail address. If you are already collecting this data on your applications sign-up form it would be helpful if these fields were already filled in on the subscription page. You can easily pass this data along to Spreedly by adding some GET variables onto the URL we constructed above:</p>
<ul>
<li>email=someone@someplace.com</li>
<li>first_name=someone</li>
<li>last_name=special</li>
</ul>
<p>If we use the above GET variables to pass additional information to our subscription forms, then our final Spreedly URL is going to look something like this:</p>
<p><strong>https://spreedly.com/signupsheet/subscribers/84736/subscribe/1019/screen-name-for-84736<span style="color: #993300;">?email=someone@someplace.com&amp;first_name=someone&amp;last_name=special</span></strong></p>
<p>That&#8217;s all there is to it. Once the user inputs their credit card information they will be redirected to the URL which you specified in the subscription plan settings. You can also modify this on the fly by providing an additional GET variable to your URL: return_url. Using that variable you can dynamically redirect the user wherever you specify upon successfully completing the payment process. This comes in handy if you need to pass any kind of dynamic information along with your user when they are redirected back to your site.</p>
<p><a href="http://www.christophermonnat.com/wp-content/uploads/2010/04/spreedly-checkout.png"><img class="aligncenter size-full wp-image-1002" title="spreedly-checkout" src="http://www.christophermonnat.com/wp-content/uploads/2010/04/spreedly-checkout.png" alt="" width="595" height="553" /></a></p>
<h2>What&#8217;s Next?</h2>
<p>If you followed along you should now be up and running with using Spreedly to manage your applications payment processing. You may however notice one thing is missing&#8230; we have no way of knowing whether the payment was processed successfully or not. The user simply gets redirected where we say and that&#8217;s it. We also have no way of knowing when their subscription expires (unless we track that ourselves). In the next post I will look at how we open up the lines of communication between Spreedly and our applications so that we know more about whose paying and whose not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2010/04/speedy-subscriptions-using-spreedly-part-3-the-sign-up-process/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Entrepreneur Heal Thyself</title>
		<link>http://www.christophermonnat.com/2009/12/entrepreneur-heal-thyself/</link>
		<comments>http://www.christophermonnat.com/2009/12/entrepreneur-heal-thyself/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 19:24:30 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=899</guid>
		<description><![CDATA[As a freelancer or sole proprietor, how do you decide when to start a new project? I&#8217;m not talking about taking on client projects&#8230; I&#8217;m referring to ventures, product or application ideas that you have and think would make a good business. Are you the kind of person who gets an idea in their head one day and jumps in head first the next? Or, do you need to have a plan in place with potential return on investment before you pick up your mouse? Until recently, I would have said that I fell in between those two extremes landing a bit closer to needing a plan than jumping in. However, over the last several months I have come to the conclusion that I fall smack dab in the first group and have determined that that&#8217;s not necessarily a good thing. To program, or not to program that is the question If you have spent any time on this site or on LOCCs you will have some idea of the projects I&#8217;m involved with. I developed BadgeTracker about 5 years ago, Sign-Up-Sheet.com followed about a year or two later accompanied most recently by myScoutPath and ScoutMailer. Contrary to most entrepreneurs I actually found my niche after I had developed a product. BadgeTracker was developed quickly and gained a following and after a little research I determined that the scouting industry was an attractive market to compete in so I selected it as my niche. The products that followed were aimed at scouts first and other groups second and I saw that as having great potential. The problem here, that I didn&#8217;t realize until just recently, is that I had taken on too much. While I do outsource some work to contractors I am the only programmer, support person and business administrator I got. That means that while I&#8217;m answering support e-mails development stops. While I&#8217;m following up on overdue invoices no one is following up with the sales leads. While I&#8217;m programming no one is marketing. This lead to having 3 or 4 mediocre projects/products that were moving forward at a snails pace. I had jumped head first into any idea that popped into my head, investing time and money to get it online and then ran out of resources to sustain, support and grow them. This lead to a great deal of frustration on my part because I was unable to work on the things I wanted to work on, investigate new ideas and opportunities or even write on my blog because I was stuck in the muck. Wait&#8230; where&#8217;s the money? Some of you may be wondering why I didn&#8217;t hire a staff or assistants to help maintain some of this. The short answer is the money wasn&#8217;t there. While the scouting industry may have looked like an attractive market at first, I have found over the years that working with non-profits is somewhat complicated and making a sale is difficult needle to thread. So while I was making some money it wasn&#8217;t enough to hire help or even leave my day job to dedicate more time. All of this of course contributed to more frustration on my part which is a very unproductive mind set to be in. Recovery What this all boils down to is not having a good vision and plan in place for the business. I should have slowed things down and investigated new ideas a bit more before jumping in a starting development and I should have finished one thing before starting another. I&#8217;m sick and tired of being sick and tired so I think it&#8217;s time for a new plan. The one thing that all great businesses have in common is  great products. There are plenty of businesses out there with mediocre products and they come and go each year along with whatever is &#8220;in&#8221; at the time. I have decided that I&#8217;m not content with creating mediocre products&#8230; I&#8217;m out to create a great product and doing that requires focus. So I&#8217;ve come to the conclusion that I need to &#8220;reboot&#8221; and start 2010 with a new plan/vision. I think Dr. Charles Emerson Winchester III, from M.A.S.H, put it best when he said &#8220;I do one thing at a time, I do it very well and then I move on.&#8221; This probably means some of my many projects and ideas may be discontinued or abandoned to drift with the current but I&#8217;m confident that this is a better approach than what I have been trying.]]></description>
			<content:encoded><![CDATA[<p>As a freelancer or sole proprietor, how do you decide when to start a new project? I&#8217;m not talking about taking on client projects&#8230; I&#8217;m referring to ventures, product or application ideas that you have and think would make a good business. Are you the kind of person who gets an idea in their head one day and jumps in head first the next? Or, do you need to have a plan in place with potential return on investment before you pick up your mouse? Until recently, I would have said that I fell in between those two extremes landing a bit closer to needing a plan than jumping in. However, over the last several months I have come to the conclusion that I fall smack dab in the first group and have determined that that&#8217;s not necessarily a good thing.</p>
<p><span id="more-899"></span></p>
<h2>To program, or not to program that is the question</h2>
<p>If you have spent any time on this site or on <a href="http://leftofcentercom.com">LOCCs</a> you will have some idea of the projects I&#8217;m involved with. I developed BadgeTracker about 5 years ago, Sign-Up-Sheet.com followed about a year or two later accompanied most recently by myScoutPath and ScoutMailer. Contrary to most entrepreneurs I actually found my niche <strong>after</strong> I had developed a product. BadgeTracker was developed quickly and gained a following and after a little research I determined that the scouting industry was an attractive market to compete in so I selected it as my niche. The products that followed were aimed at scouts first and other groups second and I saw that as having great potential.</p>
<p>The problem here, that I didn&#8217;t realize until just recently, is that I had taken on too much. While I do outsource some work to contractors I am the only programmer, support person and business administrator I got. That means that while I&#8217;m answering support e-mails development stops. While I&#8217;m following up on overdue invoices no one is following up with the sales leads. While I&#8217;m programming no one is marketing. This lead to having 3 or 4 mediocre projects/products that were moving forward at a snails pace.</p>
<p>I had jumped head first into any idea that popped into my head, investing time and money to get it online and then ran out of resources to sustain, support and grow them. This lead to a great deal of frustration on my part because I was unable to work on the things I wanted to work on, investigate new ideas and opportunities or even write on my blog because I was stuck in the muck.</p>
<h2>Wait&#8230; where&#8217;s the money?</h2>
<p>Some of you may be wondering why I didn&#8217;t hire a staff or assistants to help maintain some of this. The short answer is the money wasn&#8217;t there. While the scouting industry may have looked like an attractive market at first, I have found over the years that working with non-profits is somewhat complicated and making a sale is difficult needle to thread. So while I was making some money it wasn&#8217;t enough to hire help or even leave my day job to dedicate more time. All of this of course contributed to more frustration on my part which is a very unproductive mind set to be in.</p>
<h2>Recovery</h2>
<p>What this all boils down to is not having a good vision and plan in place for the business. I should have slowed things down and investigated new ideas a bit more before jumping in a starting development and I should have finished one thing before starting another. I&#8217;m sick and tired of being sick and tired so I think it&#8217;s time for a new plan.</p>
<p>The one thing that all great businesses have in common is  great products. There are plenty of businesses out there with mediocre products and they come and go each year along with whatever is &#8220;in&#8221; at the time. I have decided that I&#8217;m not content with creating mediocre products&#8230; I&#8217;m out to create a great product and doing that requires focus. So I&#8217;ve come to the conclusion that I need to &#8220;reboot&#8221; and start 2010 with a new plan/vision. I think Dr. Charles Emerson Winchester III, from M.A.S.H, put it best when he said &#8220;I do one thing at a time, I do it very well and then I move on.&#8221; This probably means some of my many projects and ideas may be discontinued or abandoned to drift with the current but I&#8217;m confident that this is a better approach than what I have been trying.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2009/12/entrepreneur-heal-thyself/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simplified Compatibility Checking</title>
		<link>http://www.christophermonnat.com/2009/06/simplify-compatibility-checking/</link>
		<comments>http://www.christophermonnat.com/2009/06/simplify-compatibility-checking/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 15:45:01 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=851</guid>
		<description><![CDATA[Fever, a new RSS feed reading application, just launched recently. Many of you might be familiar with the developer Shaun Inman from his popular stats tracking app Mint. I haven&#8217;t personally used Mint but I&#8217;m a huge fan of RSS feeds so when I heard about Fever I had to give it a shot. I will probably talk about the application a little later after I&#8217;ve had a chance to play with it. But, in this post I wanted to talk briefly about the unique checkout process Shaun uses to help make sure his users are installing the program on a compatable system before they even enter their credit card number. One of the difficulties when selling software that needs to be installed is making sure the software is compatible with the users computer/system. I know this is supposed to be a responsibility of the user, but if they make a mistake they will be contacting you for support. Fever takes a unique approach to confirming users are installing the software on compatible machines. Shaun has created a process that links a compatibility check with his checkout/licensing process so that users can only purchase a license if they are installing the program on a compatible machine. Before you can purchase a license you first download a small package that you upload to the location where you intend on installing the program. From there the package checks your systems compatibility and asks for database information (shown in the image above). Once entered, and after privileges have been checked, you are provided with a link back to the Fever site that populates the purchase form with a unique ID. This ID, I assume, matches your site with the compatibility check performed and then you continue with purchasing the license. This process is genius! It allows the developer to prove the user is going to be installing the software on a compatible machine before selling them a license. I can image this process greatly reduces, if not eliminates, the support requests having to do with system compatibility and installation issues. Very cool idea!]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/fever-logo.png"><img class="alignright size-full wp-image-853" title="fever-logo" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/fever-logo.png" alt="fever-logo" width="110" height="58" /></a><a href="http://feedafever.com">Fever</a>, a new RSS feed reading application, just launched recently. Many of you might be familiar with the developer <a href="http://www.shauninman.com">Shaun Inman</a> from his popular stats tracking app <a href="http://haveamint.com">Mint</a>. I haven&#8217;t personally used Mint but I&#8217;m a huge fan of RSS feeds so when I heard about Fever I had to give it a shot. I will probably talk about the application a little later after I&#8217;ve had a chance to play with it. But, in this post I wanted to talk briefly about the unique checkout process Shaun uses to help make sure his users are installing the program on a compatable system before they even enter their credit card number.</p>
<p><span id="more-851"></span></p>
<p>One of the difficulties when selling software that needs to be installed is making sure the software is compatible with the users computer/system. I know this is <em>supposed</em> to be a responsibility of the user, but if they make a mistake they will be contacting you for support. Fever takes a unique approach to confirming users are installing the software on compatible machines. Shaun has created a process that links a compatibility check with his checkout/licensing process so that users can only purchase a license if they are installing the program on a compatible machine.</p>
<p style="text-align: center;"><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/fever-compatability.png"><img class="size-full wp-image-852 aligncenter" title="fever-computability" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/fever-compatability.png" alt="fever-compatibility" width="381" height="537" /></a></p>
<p style="text-align: left;">Before you can purchase a license you first download a small package that you upload to the location where you intend on installing the program. From there the package checks your systems compatibility and asks for database information (shown in the image above). Once entered, and after privileges have been checked, you are provided with a link back to the Fever site that populates the purchase form with a unique ID. This ID, I assume, matches your site with the compatibility check performed and then you continue with purchasing the license.</p>
<p>This process is genius! It allows the developer to prove the user is going to be installing the software on a compatible machine before selling them a license. I can image this process greatly reduces, if not eliminates, the support requests having to do with system compatibility and installation issues. Very cool idea!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2009/06/simplify-compatibility-checking/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Speedy Subscriptions Using Spreedly (Part 2) &#8211; Account Configuration</title>
		<link>http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-2-account-configuration/</link>
		<comments>http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-2-account-configuration/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 10:00:52 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=750</guid>
		<description><![CDATA[If you&#8217;ve ever accepted payments with PayPal you&#8217;ll know all the magic is in the settings/configuration. There are tons of configuration options that you can modify to make PayPal work just the way you like. The same holds true for Spreedly. The developers have paid attention to detail and provided us with the ability to tweak how the service interacts with your chosen payment gateway so you can get just the functionality you&#8217;re looking for. In the last post I gave you a brief introduction to Spreedly and walked you through creating your own free test account. Today we&#8217;re going to jump in head first and look at the account configuration options. For those viewers following along at home, if you look at the configuration page, I&#8217;m going to cover each section in reverse order wrapping up with setting up your subscription plans. Site Details The site details section is where, you guess it, you enter the details of the site you are going to be integrating with Spreedly. The information requested on this form is pretty straight forward so I&#8217;m just going to touch on 2 parts. URLs About half way through the form they ask for 3 URLs: Subscriber Changed Notification URL Since you are using a system that is external to your application to handle payment processing you will have to work out some way to sync the two so your sure people have only those accounts they have paid for. That&#8217;s where the subscribers changed notification URL comes into play. When subscriber data within Spreedly changes, the service will POST a comma separated value list of subscriber IDs to the address you specify here. It then becomes your responsibility to process those changes and sync them with your application. Individual user URL on your site This is the address that users visit to view their specific information in your program. Spreedly uses this address to redirect users back to your program from their update screen. Subscription selection URL on your site This is that place in your program where users can upgrade/downgrade their account. Again, Spreedly uses this address to redirect users back to your program from their system. I will come back to these URLs later in the series so go ahead and leave them blank for now. API Authentication Token At the bottom of the site details form you will find your sites API Authentication Token. This is the token you will use when interacting with the Spreedly API. Be sure to handle with care and keep it a secret&#8230; you can always generate a new one if you need to. Make note of this because we will be using it in the posts to come. Manage Site Users One of the really nice things about Spreedly is that you can add as many users to your account as you wish without hitting any limits. So, if your organization has a 10 person support/accounting team (wishful thinking perhaps) you can add them all with their own access information from the Manage Site Users section. Payment Gateway The Payment Gateway section is where you will go when you&#8217;re ready to take your site out of testing and into production. You will have to upgrade your Spreedly account from a test site to a production site and either sign-up for the monthly pricing option or bite the bullet and get a Kickstart package. For the time being, the page just displays some example CC numbers you can use to generate different errors. Subscription Plans Now to the important stuff! The Subscription Plans section is where you setup your applications different subscription plans and pricing. By default, Spreedly has setup one example plan to give you an idea how things work. I will issue one word of caution here, you CANNOT delete subscription plans. I hope this is coming soon, because I have made a mess out of my other account, but for right now it can&#8217;t be done. Just keep this in mind as you enter your plans. I want to draw your attention to 2 pieces on this form: Feature Level The feature level is the name with which you will refer to the subscription plan through the API. You want to keep this simple yet specific so you can easily match it up with a subscription type. I typically just repeat the plan name as one word lowercase just to keep it easy. Plan Type The type of plan is where you can specify if this is a regular subscription, gift subscription or free trial. This really gives you a lot of options when setting up your applications pricing structure. You can set the amount of time each plan is valid for before charging the user again (number of days or months). You can also specify if you want to require auto-recurring purchases (you only accept auto-recurring payments) or not. The sky&#8217;s the limit! That&#8217;s it! After you play around with your settings and subscription types a little bit you will have a configured Spreedly test account ready to accept subscribers. In the next post I&#8217;m going to take a break from the Spreedly specific stuff for a little while and talk about planning your sign-up/checkout process and determining how that&#8217;s going to work with your newly configured Spreedly account.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif"><img src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif" alt="" title="spreedly-logo" width="160" height="90" class="alignright size-full wp-image-776" /></a>If you&#8217;ve ever accepted payments with PayPal you&#8217;ll know all the magic is in the settings/configuration. There are tons of configuration options that you can modify to make PayPal work just the way you like. The same holds true for Spreedly. The developers have paid attention to detail and provided us with the ability to tweak how the service interacts with your chosen payment gateway so you can get just the functionality you&#8217;re looking for. In the last post I gave you a brief introduction to Spreedly and walked you through creating your own free test account. Today we&#8217;re going to jump in head first and look at the account configuration options.</p>
<p><span id="more-750"></span></p>
<p>For those viewers following along at home, if you look at the configuration page, I&#8217;m going to cover each section in reverse order wrapping up with setting up your subscription plans.</p>
<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/05/spreedly-config.gif"><img class="aligncenter size-full wp-image-792" title="spreedly-config" src="http://www.christophermonnat.com/wp-content/uploads/2009/05/spreedly-config.gif" alt="spreedly-config" width="595" height="328" /></a></p>
<h2>Site Details</h2>
<p>The site details section is where, you guess it, you enter the details of the site you are going to be integrating with Spreedly. The information requested on this form is pretty straight forward so I&#8217;m just going to touch on 2 parts.</p>
<p><center><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-site-details.gif"><img class="aligncenter size-full wp-image-795" title="spreedly-site-details" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-site-details.gif" alt="spreedly-site-details" width="490" height="371" /></a></center></p>
<p><strong>URLs</strong></p>
<p>About half way through the form they ask for 3 URLs:</p>
<ol>
<li>Subscriber Changed Notification URL
<p>Since you are using a system that is external to your application to handle payment processing you will have to work out some way to sync the two so your sure people have only those accounts they have paid for. That&#8217;s where the subscribers changed notification URL comes into play. When subscriber data within Spreedly changes, the service will POST a comma separated value list of subscriber IDs to the address you specify here. It then becomes your responsibility to process those changes and sync them with your application.</li>
<li>Individual user URL on your site
<p>This is the address that users visit to view their specific information in your program. Spreedly uses this address to redirect users back to your program from their update screen.</li>
<li>Subscription selection URL on your site
<p>This is that place in your program where users can upgrade/downgrade their account. Again, Spreedly uses this address to redirect users back to your program from their system.</li>
</ol>
<p>I will come back to these URLs later in the series so go ahead and leave them blank for now.</p>
<p><strong>API Authentication Token</strong></p>
<p>At the bottom of the site details form you will find your sites API Authentication Token. This is the token you will use when interacting with the Spreedly API. Be sure to handle with care and keep it a secret&#8230; you can always generate a new one if you need to. Make note of this because we will be using it in the posts to come.</p>
<h2>Manage Site Users</h2>
<p>One of the really nice things about Spreedly is that you can add as many users to your account as you wish without hitting any limits. So, if your organization has a 10 person support/accounting team (wishful thinking perhaps) you can add them all with their own access information from the Manage Site Users section.</p>
<h2>Payment Gateway</h2>
<p>The Payment Gateway section is where you will go when you&#8217;re ready to take your site out of testing and into production. You will have to upgrade your Spreedly account from a test site to a production site and either sign-up for the monthly pricing option or bite the bullet and get a <a href="https://spreedly.com/info/kickstart/">Kickstart package</a>. For the time being, the page just displays some example CC numbers you can use to generate different errors.</p>
<h2>Subscription Plans</h2>
<p>Now to the important stuff! The Subscription Plans section is where you setup your applications different subscription plans and pricing. By default, Spreedly has setup one example plan to give you an idea how things work. I will issue one word of caution here, you CANNOT delete subscription plans. I hope this is coming soon, because I have made a mess out of my other account, but for right now it can&#8217;t be done. Just keep this in mind as you enter your plans.</p>
<p>I want to draw your attention to 2 pieces on this form:</p>
<p><center><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-subscription-plans.gif"><img class="aligncenter size-full wp-image-796" title="spreedly-subscription-plans" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-subscription-plans.gif" alt="spreedly-subscription-plans" width="490" height="383" /></a></center></p>
<p><strong>Feature Level</strong></p>
<p>The feature level is the name with which you will refer to the subscription plan through the API. You want to keep this simple yet specific so you can easily match it up with a subscription type. I typically just repeat the plan name as one word lowercase just to keep it easy.</p>
<p><strong>Plan Type</strong></p>
<p>The type of plan is where you can specify if this is a regular subscription, gift subscription or free trial. This really gives you a lot of options when setting up your applications pricing structure. You can set the amount of time each plan is valid for before charging the user again (number of days or months). You can also specify if you want to require auto-recurring purchases (you only accept auto-recurring payments) or not. The sky&#8217;s the limit!</p>
<h2>That&#8217;s it!</h2>
<p>After you play around with your settings and subscription types a little bit you will have a configured Spreedly test account ready to accept subscribers. In the next post I&#8217;m going to take a break from the Spreedly specific stuff for a little while and talk about planning your sign-up/checkout process and determining how that&#8217;s going to work with your newly configured Spreedly account.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-2-account-configuration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Speedy Subscriptions Using Spreedly (Part 1) &#8211; Overview &amp; Account Setup</title>
		<link>http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-1-service-overview-introduction/</link>
		<comments>http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-1-service-overview-introduction/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 10:00:12 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.christophermonnat.com/?p=747</guid>
		<description><![CDATA[I developed Sign-Up-Sheet.com four years ago first as a sandbox project for learning Ruby on Rails (RoR). After becoming disillusioned with RoR, I redeveloped the app in PHP using CodeIgniter (CI) and that&#8217;s where it&#8217;s been ever since. Every once and a while I try to add a new feature here or there but find it very difficult to focus any time/energy on a product that doesn&#8217;t generate any revenue. The solution to this problem, of course, is to start charging for the service. But every time I researched what was involved with accepting credit cards the complicated pricing schemes and high costs always turned me away. That was until I found Spreedly! This post kicks off a new series that will take a detailed look at Spreedly. Over the next couple of weeks, I will introduce you to the service, walk you through how their system works and give you a real world example so you can see it in action. What is Spreedly? Aside from the best thing since sliced bread&#8230; Spreedly is a service that takes the hassle out of collecting subscription fees for web based services/applications. Developing applications that use 3rd party payment gateways and that sell recurring subscriptions is a difficult and often expensive undertaking. Spreedly simplifies the process by handling the complex task of subscription management and payment processing for you so you can focus your time and money on your product. After configuring your Spreedly account and entering your subscription types and pricing scheme, the service will handle all the payment gateway interaction and user subscription management for you&#8230; no muss no fuss. Accepting payments literally becomes as easy as redirecting your user to a Spreedly URL and having them enter their credit card information. That&#8217;s it!! Supported Gateways It&#8217;s important to understand that Spreedly is not a payment gateway. Spreedly simply acts as the middle man between your application and your selected gateway using APIs. This means you will still need to find a payment gateway and merchant account (if necessary). The simplest, and cheapest, option is probably PayPal because it&#8217;s a gateway and merchant account all-in-one. But if that doesn&#8217;t work for you, Spreedly currently supports the following gateways: Authorize.net (Only US dollars) Beanstream (Only Canadian dollars) eWAY (Only Australian dollars) PayPal Website Payments Pro (also UK) PayPal Express Checkout (also UK) (does not currently support automatically recurring subscriptions) Sage Pay (formerly Protx) USA ePay (Only US dollars) They are constantly adding new gateways to the service so be sure to visit their site for the most updated list. If you don&#8217;t see your gateway listed above the odds are good that they can add it for you. Just contact their support team and they will research what&#8217;s involved. Pricing Accepting credit cards online is an expensive proposition&#8230; that&#8217;s why I have avoided it up until now. There are bank fees for merchant accounts, fees for each transaction, monthly fees for the payment gateway, etc&#8230; not to mention the percentage of each transaction that certain parities take just because they can. It&#8217;s enough to make you dizzy! The pricing for Spreedly is pretty straight forward: $19 per month + transaction fees 3% on the first 50 transactions per month 2% on transactions 51 through 5000 1% on all transactions after 5000 The thing to point out here is that the Spreedly fees will be on top of whatever your payment gateway charges. In the end you are still probably looking at a decent sum of money&#8230; but odds are it&#8217;s still cheaper (programming included) than if you went it alone or with another service. If there are too many monthly fees for you to handle, Spreedly also has another pricing option called the Kickstart package. For one single payment of $699.00 you can get a Spreedly account for life with: a frozen per-transaction fee of 1% no monthly fees and it never expires!! It pays to keep an eye on the Spreedly site (and maybe follow their Twitter account) for special offers because when they first launched Kickstart the price was $499.00 for a limited time. So there are opportunities for picking up deals if you pay attention. Account Setup Now that you have a basic understanding of what Spreedly is, let&#8217;s go ahead and create a test account. Spreedly makes it super easy to get your bearings and see how the system works without spending any money. You can sign-up for a free test account (which gives you access to everything you need) and see if it will work for you. To create your account, visit https://www.spreedly.com/signup and fill out the form. After signing-up you will be directed to your test site overview page (shown above). The overview page gives you a summary of your account in terms of transactions and subscribers. You can click around the interface if you like but it&#8217;s going to be pretty empty until we start submitting transactions (which we&#8217;ll get to later in this series). That&#8217;s a wrap That does it for the Spreedly intro. In the next post I will review how to configure your account and setup your subscription plans/pricing scheme. I&#8217;m just getting started with Spreedly so stay tuned!]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif"><img class="alignright size-full wp-image-776" title="spreedly-logo" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-logo.gif" alt="spreedly-logo" width="160" height="90" /></a>I developed <a href="http://www.sign-up-sheet.com">Sign-Up-Sheet.com</a> four years ago first as a sandbox project for learning Ruby on Rails (RoR). After becoming disillusioned with RoR, I redeveloped the app in PHP using <a href="http://www.codeigniter.com">CodeIgniter</a> (CI) and that&#8217;s where it&#8217;s been ever since. Every once and a while I try to add a new feature here or there but find it very difficult to focus any time/energy on a product that doesn&#8217;t generate any revenue. The solution to this problem, of course, is to start charging for the service. But every time I researched what was involved with accepting credit cards the complicated pricing schemes and high costs always turned me away. That was until I found <a href="http://www.spreedly.com">Spreedly</a>! This post kicks off a new series that will take a detailed look at Spreedly. Over the next couple of weeks, I will introduce you to the service, walk you through how their system works and give you a real world example so you can see it in action.<br />
<span id="more-747"></span></p>
<h2>What is Spreedly?</h2>
<p>Aside from the best thing since sliced bread&#8230; Spreedly is a service that takes the hassle out of collecting subscription fees for web based services/applications. Developing applications that use 3rd party payment gateways and that sell recurring subscriptions is a difficult and often expensive undertaking. Spreedly simplifies the process by handling the complex task of subscription management and payment processing for you so you can focus your time and money on your product.</p>
<p>After configuring your Spreedly account and entering your subscription types and pricing scheme, the service will handle all the payment gateway interaction and user subscription management for you&#8230; no muss no fuss. Accepting payments literally becomes as easy as redirecting your user to a Spreedly URL and having them enter their credit card information. That&#8217;s it!!</p>
<h2>Supported Gateways</h2>
<p>It&#8217;s important to understand that <strong>Spreedly is not a payment gateway</strong>. Spreedly simply acts as the middle man between your application and your selected gateway using APIs. This means you will still need to find a payment gateway and merchant account (if necessary). The simplest, and cheapest, option is probably <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside">PayPal</a> because it&#8217;s a gateway and merchant account all-in-one. But if that doesn&#8217;t work for you, Spreedly currently supports the following gateways:</p>
<ul>
<li><a href="http://www.authorize.net/">Authorize.net</a> (Only US dollars)</li>
<li><a href="http://www.beanstream.com/">Beanstream</a> (Only Canadian dollars)</li>
<li><a href="http://www.eway.com.au/">eWAY</a> (Only Australian dollars)</li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside">PayPal Website Payments Pro</a> (also <a href="https://www.paypal.com/uk/cgi-bin/webscr?cmd=_wp-pro-overview-outside">UK</a>)</li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_additional-payment-overview-outside">PayPal Express Checkout</a> (also <a href="https://www.paypal.com/uk/cgi-bin/webscr?cmd=_additional-payment-overview-outside">UK</a>)<br />
(does not currently support automatically recurring subscriptions)</li>
<li><a href="http://www.sagepay.com/">Sage Pay</a> (formerly Protx)</li>
<li><a href="http://usaepay.com/">USA ePay</a> (Only US dollars)</li>
</ul>
<p>They are constantly adding new gateways to the service so be sure to visit <a href="http://www.spreedly.com/info/payment-gateways/">their site</a> for the most updated list. If you don&#8217;t see your gateway listed above the odds are good that they can add it for you. Just contact their support team and they will research what&#8217;s involved.</p>
<h2>Pricing</h2>
<p>Accepting credit cards online is an expensive proposition&#8230; that&#8217;s why I have avoided it up until now. There are bank fees for merchant accounts, fees for each transaction, monthly fees for the payment gateway, etc&#8230; not to mention the percentage of each transaction that certain parities take just because they can. It&#8217;s enough to make you dizzy!</p>
<p>The pricing for Spreedly is pretty straight forward:</p>
<p><strong>$19 per month + transaction fees</strong></p>
<ul>
<li>3% on the first 50 transactions per month</li>
<li>2% on transactions 51 through 5000</li>
<li>1% on all transactions after 5000</li>
</ul>
<p>The thing to point out here is that the Spreedly fees will be on top of whatever your payment gateway charges. In the end you are still probably looking at a decent sum of money&#8230; but odds are it&#8217;s still cheaper (programming included) than if you went it alone or with another service.</p>
<p>If there are too many monthly fees for you to handle, Spreedly also has another pricing option called the <a href="http://www.spreedly.com/info/kickstart/">Kickstart package</a>. For one single payment of $699.00 you can get a Spreedly account <strong>for life</strong> with:</p>
<ul>
<li>a frozen per-transaction fee of 1%</li>
<li>no monthly fees</li>
<li>and it never expires!!</li>
</ul>
<p>It pays to keep an eye on the Spreedly site (and maybe follow their <a href="http://twitter.com/spreedly">Twitter account</a>) for special offers because when they first launched Kickstart the price was $499.00 for a limited time. So there are opportunities for picking up deals if you pay attention.</p>
<h2>Account Setup</h2>
<p>Now that you have a basic understanding of what Spreedly is, let&#8217;s go ahead and create a test account. Spreedly makes it super easy to get your bearings and see how the system works without spending any money. You can sign-up for a free test account (which gives you access to everything you need) and see if it will work for you. To create your account, visit <a href="https://www.spreedly.com/signup">https://www.spreedly.com/signup</a> and fill out the form.</p>
<p><a href="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-overview.gif"><img class="aligncenter size-full wp-image-789" title="spreedly-overview" src="http://www.christophermonnat.com/wp-content/uploads/2009/06/spreedly-overview.gif" alt="spreedly-overview" width="595" height="351" /></a></p>
<p>After signing-up you will be directed to your test site overview page (shown above). The overview page gives you a summary of your account in terms of transactions and subscribers. You can click around the interface if you like but it&#8217;s going to be pretty empty until we start submitting transactions (which we&#8217;ll get to later in this series).</p>
<h2>That&#8217;s a wrap</h2>
<p>That does it for the Spreedly intro. In the next post I will review how to configure your account and setup your subscription plans/pricing scheme.</p>
<p>I&#8217;m just getting started with Spreedly so stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophermonnat.com/2009/06/speedy-subscriptions-using-spreedly-part-1-service-overview-introduction/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

