<?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>My Science Is Better &#187; zend_service_twitter</title>
	<atom:link href="http://www.myscienceisbetter.info/tag/zend_service_twitter/feed" rel="self" type="application/rss+xml" />
	<link>http://www.myscienceisbetter.info</link>
	<description></description>
	<lastBuildDate>Sat, 20 Mar 2010 16:16:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to update your Twitter status using Zend Framework</title>
		<link>http://www.myscienceisbetter.info/how-to-update-your-twitter-status-using-zend-framework.html</link>
		<comments>http://www.myscienceisbetter.info/how-to-update-your-twitter-status-using-zend-framework.html#comments</comments>
		<pubDate>Tue, 22 Sep 2009 09:30:20 +0000</pubDate>
		<dc:creator>Romeo Adrian Cioaba</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[zend_service_twitter]]></category>

		<guid isPermaLink="false">http://www.myscienceisbetter.info/?p=91</guid>
		<description><![CDATA[After reading the NetTuts tutorial on how to update your Twitter status using CodeIgniter, I wanted to show how to update your Twitter status using Zend Framework.
For this tutorial you need to install Zend Framework and Zend_Tool first.
Step 1: setup apache vhost by creating the /etc/apache2/sites-available/twitter as follows:

&#60;VirtualHost *:80&#62;

    ServerAdmin romeo.cioaba@spotonearth.com
  [...]]]></description>
			<content:encoded><![CDATA[<p>After reading the NetTuts tutorial on how to <a href="http://net.tutsplus.com/tutorials/php/how-to-update-your-twitter-status-with-codeigniter/" target="_blank">update your Twitter status using CodeIgniter</a>, I wanted to show <a title="How to update your Twitter status using Zend Framework" href="http://www.myscienceisbetter.info/how-to-update-your-twitter-status-using-zend-framework.html">how to update your Twitter status using Zend Framework</a>.</p>
<p>For this tutorial you need to <a title="Install Zend Framework and Zend_Tool using PEAR on Ubuntu" href="http://www.myscienceisbetter.info/install-zend-framework-and-zend_tool-using-pear-on-ubuntu.html">install Zend Framework and Zend_Tool</a> first.</p>
<p>Step 1: setup apache vhost by creating the /etc/apache2/sites-available/twitter as follows:</p>
<pre class="brush: bash;">
&lt;VirtualHost *:80&gt;

    ServerAdmin romeo.cioaba@spotonearth.com
    DocumentRoot /home/mimir/Zend/workspaces/DefaultWorkspace7/twitter
    ServerName twitter.dev
    ServerAlias www.twitter.dev
    ErrorLog /home/mimir/Zend/workspaces/DefaultWorkspace7/logs/twitter_error_log
    CustomLog /home/mimir/Zend/workspaces/DefaultWorkspace7/logs/twitter_access_log combined

    &lt;Directory &quot;/home/mimir/Zend/workspaces/DefaultWorkspace7/twitter/&quot;&gt;
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
    &lt;/Directory&gt;

&lt;/VirtualHost&gt;
</pre>
<p>You will need to change the DocumentRoot and Directory directives to match your configuration.</p>
<p>Step 2: add twitter.dev to your hosts file:</p>
<pre class="brush: bash;">
127.0.0.1	twitter.dev www.twitter.dev
</pre>
<p>Step 3: create the Zend Framework project</p>
<pre class="brush: bash;">
# i switch to my Zend Studio workspace, where apache is reading his sites from:
# cd Zend/workspaces/DefaultWorkspace7/
zf create project twitter
</pre>
<p>Step 4: restart apache</p>
<pre class="brush: bash;">
sudo /etc/init.d/apache2 restart
</pre>
<p>At this point you should have a default Zend Framework project that you can browse at http://twitter.dev/public/. How let's change our status <img src='http://www.myscienceisbetter.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Replace the content of IndexController with the following:</p>
<pre class="brush: php;">
&lt;?php
class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // we create the form
        $updateForm = new Zend_Form();

        $status = new Zend_Form_Element_Text('status');
        $status-&gt;setLabel('New Twitter Status')
               -&gt;setRequired(true)
               -&gt;addFilter('StripTags')
               -&gt;addFilter('StringTrim')
               -&gt;addValidator('NotEmpty');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit-&gt;setLabel('Update');

        $updateForm-&gt;addElements(array($status, $submit));

        // we send the form to the view
        $this-&gt;view-&gt;updateForm = $updateForm;

        // we check if there was any POST
        if ($this-&gt;getRequest()-&gt;isPost()){
            $formData = $this-&gt;_request-&gt;getPost();
            // checking if the form data is valid (if we have a new status or not)
            if ($this-&gt;view-&gt;updateForm-&gt;isValid($formData)){
                // our form is valid, we can update our status
                $twitterStatus = $formData['status'];

                $twitter = new Zend_Service_Twitter('myusername', 'mypassword');
                $response = $twitter-&gt;status-&gt;update($twitterStatus);
            }
        }

    }

}
</pre>
<p>Also replace the view for the index action of IndexController with:</p>
<pre class="brush: php;">

&lt;h1&gt;Welcome to the Twitter Update Tutorial&lt;/h1&gt;

&lt;?php echo $this-&gt;updateForm?&gt;
</pre>
<p>TADA! You can now check your twitter account and see that twitter status is updated every time you submit the form -:)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.myscienceisbetter.info/how-to-update-your-twitter-status-using-zend-framework.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
