<?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>Fernando Marcelo.com</title>
	<atom:link href="http://fernandomarcelo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fernandomarcelo.com</link>
	<description>Just some dev stuff.</description>
	<lastBuildDate>Tue, 11 Feb 2014 20:01:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>Becoming a better programmer: one new technology per month</title>
		<link>http://fernandomarcelo.com/2014/02/becoming-a-better-programmer-one-new-technology-per-month/</link>
					<comments>http://fernandomarcelo.com/2014/02/becoming-a-better-programmer-one-new-technology-per-month/#respond</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Sat, 15 Feb 2014 19:50:40 +0000</pubDate>
				<category><![CDATA[New techs]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=109</guid>

					<description><![CDATA[I have been trying to do this for quite sometime but it was hard for keep it, specially when there are a lot of pending work stuff. The idea is to learn a new technology per month. It can a framework, a programming language or a concept. It doesn&#8217;t matter. The main idea is to keep [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="line-height: 1.5em;">I have been trying to do this for quite sometime but it was hard for keep it, specially when there are a lot of pending work stuff.</span></p>
<p>The idea is to learn a new technology per month. It can a framework, a programming language or a concept. It doesn&#8217;t matter. The main idea is to keep open-minded about it without thinking that you could be doing the same task with your preferred language in way less time.</p>
<p>This already gave some nice results like learning Ruby On Rails which became my (current) web framework of choice.</p>
<p><span style="line-height: 1.5em;">At the beginning of 2014 I decided (again!) that I would do this, but with a small difference, I will post an article at the end of the month showing my impressions of the technology: what I liked, what I disliked, what I might use for some of my projects etc.</span></p>
<p><span style="line-height: 1.5em;">The first post should be out in a few days. I&#8217;m looking forward to post 12 articles about this in 2014.</span></p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2014/02/becoming-a-better-programmer-one-new-technology-per-month/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Exporting PowerDNS zones to Cloudflare: AXFR mode</title>
		<link>http://fernandomarcelo.com/2014/02/exporting-powerdns-zones-to-cloudflare-axfr-mode/</link>
					<comments>http://fernandomarcelo.com/2014/02/exporting-powerdns-zones-to-cloudflare-axfr-mode/#comments</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Tue, 11 Feb 2014 19:46:41 +0000</pubDate>
				<category><![CDATA[Sysadmin]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=105</guid>

					<description><![CDATA[Cloudflare does its best to detect all DNS records on your domain but if you have a complex setup with uncommon subdomains it won&#8217;t detect everything. You can import your DNS records by uploading a BIND zone file, unfortunately you might be using another server like PowerDNS. One way that I found out is to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Cloudflare does its best to detect all DNS records on your domain but if you have a complex setup with uncommon subdomains it won&#8217;t detect everything.</p>
<p>You can import your DNS records by uploading a BIND zone file, unfortunately you might be using another server like PowerDNS.</p>
<p>One way that I found out is to use AXFR.</p>
<p><strong>1) Enable AXFR in PowerDNS</strong></p>
<p>Search for the following line in PowerDNS configuration:</p>
<blockquote><p>disable-axfr=yes</p></blockquote>
<p>Change it to:</p>
<blockquote><p>disable-axfr=no</p></blockquote>
<p>And restart PowerDNS.</p>
<p>Note that AXFR exposes all DNS records in all domains at your server. You might want to turn it off after the transfer is done.</p>
<p><strong>2) Use dig to do a AXFR request and export everything</strong></p>
<blockquote><p>dig  +short axfr yourdomain.com &gt; zonefile.txt</p></blockquote>
<p>This will dump all records on a file called zonefile.txt.</p>
<p><strong>3) Add your domain to Cloudflare and upload zonefile.txt</strong></p>
<p>Just after adding your domain to Cloudflare, at the second step, you have the option to upload a zone file. Simply upload the file that was generated and, although it&#8217;s not a BIND zone file, it will work perfectly and all records should be imported.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2014/02/exporting-powerdns-zones-to-cloudflare-axfr-mode/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Testing Focus@Will</title>
		<link>http://fernandomarcelo.com/2014/02/testing-focus-at-will/</link>
					<comments>http://fernandomarcelo.com/2014/02/testing-focus-at-will/#respond</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Sun, 02 Feb 2014 13:40:12 +0000</pubDate>
				<category><![CDATA[Productivity]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=96</guid>

					<description><![CDATA[Three days ago I found out about about this amazing service called Focus@Will. It&#8217;s a service that promises to improve your focus while working by using the right music ( more info at their FAQ ). It&#8217;s a bit earlier for any permanent conclusions but just after the first section I started to get some [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Three days ago I found out about about this amazing service called <a href="https://www.focusatwill.com/">Focus@Will</a>.</p>
<p>It&#8217;s a service that promises to improve your focus while working by using the right music ( more info at their <a href="https://www.focusatwill.com/faq/">FAQ</a> ).</p>
<p>It&#8217;s a bit earlier for any permanent conclusions but just after the first section I started to get some productivity boosts at the point that I could work on a task for 4 hours without a single distraction. Not even a quick look at Twitter or Hacker News!</p>
<p>They offer several genre options. The strange thing is that what I have been listening a lot is the Up Tempo with High energy level, usually something that I wouldn&#8217;t listen for entertainment since it&#8217;s not a genre that i appreciate.</p>
<p>I will post again after some weeks of testing. Let&#8217;s see if I can keep my productivity high.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2014/02/testing-focus-at-will/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Rails Admin: creating a custom action</title>
		<link>http://fernandomarcelo.com/2012/05/rails-admin-creating-a-custom-action/</link>
					<comments>http://fernandomarcelo.com/2012/05/rails-admin-creating-a-custom-action/#comments</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Fri, 11 May 2012 01:59:24 +0000</pubDate>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rails admin]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=76</guid>

					<description><![CDATA[Rails Admin is an excellent way of quickly creating a backend for your website. It&#8217;s simply perfect for that project that is focused on frontend but you still need a backend to do simple management tasks. Although it&#8217;s very complete, sometimes you may want to customize a few things and for this you can create [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Rails Admin is an excellent way of quickly creating a backend for your website. It&#8217;s simply perfect for that project that is focused on frontend but you still need a backend to do simple management tasks.</p>
<p>Although it&#8217;s very complete, sometimes you may want to customize a few things and for this you can create a custom action.</p>
<p><span id="more-76"></span></p>
<p>If you have, for example, a list of articles. It would be good if you could bulk publish them, instead of going and editing one by one. Fortunately this is possible and quite simple, although it&#8217;s not very clear in Rails Admin manual.</p>
<p><strong>1. Create your custom action</strong></p>
<p>Let&#8217;s create our custom action. Create file <strong>lib/rails_admin_publish.rb</strong> with the following content:</p>
<pre class="brush: ruby; title: ; notranslate">
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'

module RailsAdminPublish
end

module RailsAdmin
  module Config
    module Actions
      class Publish &lt; RailsAdmin::Config::Actions::Base
        # There are several options that you can set here. 
        # Check https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/actions/base.rb for more info.

        register_instance_option :bulkable? do
          true
        end

        register_instance_option :controller do
          Proc.new do
            # Get all selected rows
            @objects = list_entries(@model_config, :destroy)

            # Update field published to true
            @objects.each do |object|
              object.update_attribute(:published, true)
            end

            flash&#x5B;:success] = &quot;#{@model_config.label} successfully published.&quot;

            redirect_to back_or_index
          end
        end
      end
    end
  end
end
</pre>
<p>What exactly this does? Well, first it defines this action as bulkable. There are many other options that you can set here, check the comment next to that line for more information.</p>
<p>After that, we create a Proc with our action. In summary, it&#8217;s getting all entries and looping to update the attribute published. After that, it sets a flash message and redirect to index.</p>
<p><strong>2. Let Rails Admin know that your custom action exists</strong></p>
<p>Open <strong>config/initializers/rails_admin.rb</strong> and add the following code <strong>before</strong> RailsAdmin.config:</p>
<pre class="brush: ruby; title: ; notranslate">require Rails.root.join('lib', 'rails_admin_publish.rb')</pre>
<p>Them add this <strong>inside</strong> RailsAdmin.config:</p>
<pre class="brush: ruby; title: ; notranslate">
# Register the class in lib/rails_admin_publish.rb
module RailsAdmin
  module Config
    module Actions
      class Publish &lt; RailsAdmin::Config::Actions::Base
        RailsAdmin::Config::Actions.register(self)
      end
    end
  end
end

c.actions do
  # root actions
  dashboard                     # mandatory
  # collection actions
  index                         # mandatory
  new
  export
  history_index
  bulk_delete
  # member actions
  show
  edit
  delete
  history_show
  show_in_app

  # Set the custom action here
  publish do
    # Make it visible only for article model. You can remove this if you don't need.
    visible do
      bindings&#x5B;:abstract_model].model.to_s == &quot;Article&quot;
    end
  end
end
</pre>
<p>What it does is to first register the publish action and them tell Rails Admin where it should be visible. If you want to make it visible for all models, simply remove that visible part and it should work correctly.</p>
<p>That&#8217;s it, restart your server and test. The bulk action should be there.</p>
<p>In case you still have questions I&#8217;ve forked dummy_app, which is a sample app created to show Rails Admin, and used it to create a custom action. Check it out in Github <a href="https://github.com/fernandomm/dummy_app">https://github.com/fernandomm/dummy_app</a></p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2012/05/rails-admin-creating-a-custom-action/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>Paperclip: how to move existing attachments to a new path</title>
		<link>http://fernandomarcelo.com/2012/05/paperclip-how-to-move-existing-attachments-to-a-new-path/</link>
					<comments>http://fernandomarcelo.com/2012/05/paperclip-how-to-move-existing-attachments-to-a-new-path/#comments</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Thu, 10 May 2012 03:17:37 +0000</pubDate>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=68</guid>

					<description><![CDATA[I made the mistake of using the default Paperclip url/path for multiple models, which is problem if an user upload a file with the same name and id, causing a conflict. Also, using the same directory for different models is kind of messy. Here are the steps that i took to fix this problem: 1. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I made the mistake of using the default Paperclip url/path for multiple models, which is problem if an user upload a file with the same name and id, causing a conflict. Also, using the same directory for different models is kind of messy.</p>
<p>Here are the steps that i took to fix this problem:</p>
<p><span id="more-68"></span></p>
<p><strong>1. Change the path/url in model</strong></p>
<p>Before:</p>
<pre class="brush: ruby; title: ; notranslate">
class User &lt; ActiveRecord::Base
  has_attached_file :image
end
&amp;#91;/ruby&amp;#93;

After:

&amp;#91;ruby&amp;#93;
class User &lt; ActiveRecord::Base
  has_attached_file :image,
     :path =&gt; &quot;:rails_root/public/system/users/images/:id/:style/:filename&quot;,
     :url =&gt; &quot;/system/users/images/:id/:style/:filename&quot;
end
</pre>
<p>This will make them to be stored in public/system/users/images/. If you have other models like Post or Article, edit them too but use different paths.</p>
<p><strong>2. Move your current data</strong></p>
<p>If you already have some files, it&#8217;s time to move them as Paperclip won&#8217;t do it for you. To do it i created a rake task. Place it in <strong>lib/tasks/copy_paperclip_data.rake</strong>:</p>
<pre class="brush: ruby; title: ; notranslate">
desc &quot;Copy paperclip data&quot;
task :copy_paperclip_data =&gt; :environment do
  @users = User.find :all
  @users.each do |user|
    unless user.image_file_name.blank?
      filename = Rails.root.join(&#039;public&#039;, &#039;system&#039;, &#039;images&#039;, user.id.to_s, &#039;original&#039;, user.image_file_name)

      if File.exists? filename
        image = File.new filename
        user.image = image
        user.save

        image.close
      end
    end
  end
end
</pre>
<p>You probably have to adapt this in case you are working on another model or field. In this case, i&#8217;m working on model Users and field image.</p>
<p>Note that i&#8217;m <strong>copying data</strong>. In case something goes wrong, you can revert it back. Remove it after you&#8217;re done.</p>
<p>Now simply run:</p>
<pre class="brush: plain; title: ; notranslate">
rake copy_paperclip_data
</pre>
<p>Hope this helps you.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2012/05/paperclip-how-to-move-existing-attachments-to-a-new-path/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>Uncaught exception &#8216;Zend_Application_Resource_Exception&#8217; with message &#8216;Bootstrap file found for module &#8220;default&#8221;</title>
		<link>http://fernandomarcelo.com/2011/08/uncaught-exception-zend_application_resource_exception-with-message-bootstrap-file-found-for-module-default/</link>
					<comments>http://fernandomarcelo.com/2011/08/uncaught-exception-zend_application_resource_exception-with-message-bootstrap-file-found-for-module-default/#comments</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 01:57:03 +0000</pubDate>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[zend framework exceptions]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=59</guid>

					<description><![CDATA[Getting this error after moving your ZF application to use modules? Fatal error: Uncaught exception 'Zend_Application_Resource_Exception' with message 'Bootstrap file found for module "default" but bootstrap class "Default_Bootstrap" not found' This usually happens if you declare your controllerDirectory on Front Controller before defining a different defaultModule. Something like this on application.ini: resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.defaultModule [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Getting this error after moving your ZF application to use modules?</p>
<pre>Fatal error: Uncaught exception 'Zend_Application_Resource_Exception'
with message 'Bootstrap file found for module "default" but
bootstrap class "Default_Bootstrap" not found'</pre>
<p>This usually happens if you declare your <strong>controllerDirectory</strong> on Front Controller <strong>before</strong> defining a different <strong>defaultModule</strong>.</p>
<p>Something like this on application.ini:</p>
<pre>resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.defaultModule = "core"</pre>
<p>Removing controllerDirectory declaration should do the trick ( it&#8217;s not necessary since you are using modules ).</p>
<p>Or, you can simply place it below defaultModule declaration.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2011/08/uncaught-exception-zend_application_resource_exception-with-message-bootstrap-file-found-for-module-default/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Starting to use github</title>
		<link>http://fernandomarcelo.com/2010/10/starting-to-use-github/</link>
					<comments>http://fernandomarcelo.com/2010/10/starting-to-use-github/#respond</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Thu, 14 Oct 2010 22:58:39 +0000</pubDate>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[github]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=35</guid>

					<description><![CDATA[From now on, i will be using github to post the code used on all tutorials. I am still learning more about git, but it seems like a great tool 🙂 Here is the repository for all blog tutorials: http://github.com/fernandomm/Blog-Tutorials]]></description>
										<content:encoded><![CDATA[<p>From now on, i will be using github to post the code used on all tutorials.</p>
<p>I am still learning more about git, but it seems like a great tool <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Here is the repository for all blog tutorials: <a href="http://github.com/fernandomm/Blog-Tutorials">http://github.com/fernandomm/Blog-Tutorials</a></p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2010/10/starting-to-use-github/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to identify the Zend Framework version?</title>
		<link>http://fernandomarcelo.com/2010/09/how-to-identify-the-zend-framework-version/</link>
					<comments>http://fernandomarcelo.com/2010/09/how-to-identify-the-zend-framework-version/#respond</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Wed, 22 Sep 2010 23:27:38 +0000</pubDate>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[zend framework]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=32</guid>

					<description><![CDATA[Quick tip today. If you need to identify the current Zend Framework version use: echo Zend_Version::VERSION; Which will result in something like this: 1.10.8. Or open file Zend/Version.php and verify constant VERSION.]]></description>
										<content:encoded><![CDATA[<p>Quick tip today. If you need to identify the current Zend Framework version use:</p>
<pre class="brush: php; title: ; notranslate">

echo Zend_Version::VERSION;

</pre>
<p>Which will result in something like this: <strong>1.10.8</strong>.</p>
<p>Or open file <strong>Zend/Version.php</strong> and verify constant VERSION.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2010/09/how-to-identify-the-zend-framework-version/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using Zend_Service_Twitter and Zend_OAuth</title>
		<link>http://fernandomarcelo.com/2010/09/using-zend_service_twitter-and-zend_oauth/</link>
					<comments>http://fernandomarcelo.com/2010/09/using-zend_service_twitter-and-zend_oauth/#comments</comments>
		
		<dc:creator><![CDATA[Fernando]]></dc:creator>
		<pubDate>Sat, 18 Sep 2010 15:55:17 +0000</pubDate>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[zend framework]]></category>
		<guid isPermaLink="false">http://fernandomarcelo.com/?p=5</guid>

					<description><![CDATA[ZF Version: 1.10.8 The source code of this post is available at GitHub. At this short tutorial i will show to how use Zend_Service_Twitter and Zend_OAuth. I&#8217;m considering that: You have a working ZF environment. You have registered your application at Twitter.com and have the consumer key and secret. I won&#8217;t get into the details [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>ZF Version: 1.10.8</p>
<p>The source code of this post is available at <a href="http://github.com/fernandomm/Blog-Tutorials/tree/master/ZendTwitterOAuth/">GitHub</a>.</p>
<p>At this short tutorial i will show to how use Zend_Service_Twitter and Zend_OAuth. I&#8217;m considering that:</p>
<ol>
<li>You have a working ZF environment.</li>
<li> You have registered your application at Twitter.com and have the consumer key and secret.</li>
</ol>
<p>I won&#8217;t get into the details of how OAuth work, since there are many tutorials about it. But to summarize what our controller will do:</p>
<ol>
<li>User access authenticate action and it&#8217;s redirected to Twitter.com</li>
<li>If user allow application access, he gets back to our application on callback action.</li>
<li>Callback action process the request and if user is authenticated, redirect to index action.</li>
<li>Index action uses twitter service class to get user timeline ( or do other actions ).</li>
</ol>
<p>The first thing is to define a few configuration parameters. Since they are common between your controller actions, we will place it at <strong>application.ini</strong>. So open file applications/configs/application.ini and add the following lines:</p>
<pre class="brush: plain; title: ; notranslate">twitter.callbackUrl = &quot;http://localhost/twitter/callback&quot;
twitter.siteUrl = &quot;http://twitter.com/oauth&quot;
twitter.consumerKey = &quot;yourConsumerKey&quot;
twitter.consumerSecret = &quot;yourConsumerSecret&quot;</pre>
<p>The directives are self explanatory, just make sure that the callback url is set to the correct action.</p>
<p>Now that you have the config, let&#8217;s create a controller for it. In this example, it will be called twitter:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

class TwitterController extends Zend_Controller_Action
{
	public function init()
	{

	}

	public function indexAction()
	{

	}

	public function authenticateAction()
	{

	}

	public function callbackAction()
	{

	}
}
</pre>
<p>Since we will need the config variables on <strong>all actions</strong>, we define it at init method:</p>
<pre class="brush: php; title: ; notranslate">
	public function init()
	{
		// Define zend config on registry. I'm doing it here, but you probably have this on your bootstrap
		$zendConfig = new Zend_Config_Ini( APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV );
		Zend_Registry::set( 'Zend_Config' , $zendConfig );
	}
</pre>
<p>We have to redirect user to Twitter.com, so that he can allow our application to access his account. This is done at authenticate action:</p>
<pre class="brush: php; title: ; notranslate">
	public function authenticateAction()
	{
		$zendConfig = Zend_Registry::get( 'Zend_Config' );

		// Instance oauth consumer with config options
		$consumer = new Zend_Oauth_Consumer($zendConfig-&gt;twitter-&gt;toArray());

		// Using the default session namespace, we store the request token serialized
		$session = new Zend_Session_Namespace();
		$session-&gt;requestToken = serialize( $consumer-&gt;getRequestToken() );

		// Redirect user to twitter.com
		$consumer-&gt;redirect();
	}
</pre>
<p>If user clicks on allow, he will be redirected to the callback action with a series of GET parameters containing the auth info. We have to process it in order to get the access token.</p>
<pre class="brush: php; title: ; notranslate">
	public function callbackAction()
	{
		$zendConfig = Zend_Registry::get( 'Zend_Config' );

		// Instance oauth consumer with config options
		$consumer = new Zend_Oauth_Consumer($zendConfig-&gt;twitter-&gt;toArray());

		// Use default session namespace
		$session = new Zend_Session_Namespace();

		// Check if we got a get request and that  user already have a request token
		if ( !empty( $this-&gt;_request-&gt;getQuery() ) &amp;&amp; !empty( $session-&gt;requestToken ) ) {

			// Get access token
			$token = $consumer-&gt;getAccessToken( $this-&gt;_request-&gt;getQuery() , unserialize( $session-&gt;requestToken ) );

			// Store access token on a session variable. You can also store on DB, in case you want to use later
			$session-&gt;accessToken = serialize( $token );

			// Remove request token, not necessary anymore
			unset( $session-&gt;requestToken );

			// Redirect to index action
			return $this-&gt;_helper-&gt;redirector( 'index' );
		} else {
			throw new Exception( 'Invalid access. No token provided.' );
		}
	}
</pre>
<p>As you can see, if everything works user is redirected to index action. At index action, i&#8217;ve placed an example of how to get user recent tweets. Zend_Service_Twitter offers many functions, you can check them at <a href="http://www.zendframework.com/manual/en/zend.service.twitter.html">ZF manual</a>.</p>
<pre class="brush: php; title: ; notranslate">
	public function indexAction()
	{
		// Default namespace
		$session = new Zend_Session_Namespace();

		try {
			// Check if user have access token.
			if ( empty( $session-&gt;accessToken ) ) {
				throw new Exception( 'You are not logged in. Please, try again.' );
			}

			// Unserialize access token
			$token = unserialize($session-&gt;accessToken);

			$zendConfig = Zend_Registry::get( 'Zend_Config' );

			// Prepare a config array with access token and config options
			$config = $zendConfig-&gt;twitter-&gt;toArray();
			$config&#x5B;'username'] = $token-&gt;getParam( 'screen_name' );
			$config&#x5B;'accessToken'] = $token;

			$twitter = new Zend_Service_Twitter( $config );

			// Verify if credentials work
			$response = $twitter-&gt;account-&gt;verifyCredentials();

			if ( !$response || !empty( $response-&gt;error ) ) {
				throw new Exception( 'Wrong credentials. Please, try to login again.' );
			}

			// Vardump user timeline ( one tweet )
			var_dump( $twitter-&gt;status-&gt;userTimeLine() );

		} catch ( Exception $e ) {

			echo $e-&gt;getMessage();
		}

		die();
	}
</pre>
<p>That&#8217;s it. Hope you found this tutorial userful.</p>
<p>If you want, you can download the full source-code: <a href="/code/TwitterController.phps">TwitterController.php</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://fernandomarcelo.com/2010/09/using-zend_service_twitter-and-zend_oauth/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
