<?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>Life Scaling &#187; source</title>
	<atom:link href="http://orensol.com/tag/source/feed/" rel="self" type="application/rss+xml" />
	<link>http://orensol.com</link>
	<description>Oren Solomianik's Blog</description>
	<lastBuildDate>Mon, 21 Jun 2010 08:10:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PEAR&#8217;s Services_Twitter and the Source Option</title>
		<link>http://orensol.com/2009/01/13/pears-services_twitter-and-the-source-option/</link>
		<comments>http://orensol.com/2009/01/13/pears-services_twitter-and-the-source-option/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 14:31:38 +0000</pubDate>
		<dc:creator>Oren</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[PEAR]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Services_Twitter]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://orensol.wordpress.com/?p=11</guid>
		<description><![CDATA[<p>I recently started using PEAR&#8217;s <a href="http://pear.php.net/package/Services_Twitter/">Services_Twitter</a> package (still in beta) written by Joe Stump (from Digg) and David Jean Louis. My natural choice would have been Zend Framework&#8217;s <a href="http://framework.zend.com/manual/en/zend.service.twitter.html" target="_blank">Zend_Service_Twitter</a>, but I wasn&#8217;t aware that it was out of the incubator by the time I started.</p>
<p>Using and integrating the Services_Twitter package was very [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started using PEAR&#8217;s <a href="http://pear.php.net/package/Services_Twitter/">Services_Twitter</a> package (still in beta) written by Joe Stump (from Digg) and David Jean Louis. My natural choice would have been Zend Framework&#8217;s <a href="http://framework.zend.com/manual/en/zend.service.twitter.html" target="_blank">Zend_Service_Twitter</a>, but I wasn&#8217;t aware that it was out of the incubator by the time I started.</p>
<p>Using and integrating the Services_Twitter package was very easy, and didn&#8217;t require much more than copying and pasting the code from the class documentation:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Services/Twitter.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'You_Username'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Your_Password'</span><span style="color: #339933;">;</span>
&nbsp;
try <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Services_Twitter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">statuses</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I'm coding with PEAR right now!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Should be a SimpleXMLElement structure</span>
<span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Services_Twitter_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">echo</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>However, once I requested the &#8220;source&#8221; option from twitter (that nifty thing that says where the tweet was sent via), things got complicated. Apparently, when the Twitter.php factory builds an instance of an API driver, it instantiates a new object, and doesn&#8217;t pass it the current factory options, so this didn&#8217;t work:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Services_Twitter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOptions</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'source'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'myapp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">statuses</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I'm coding with PEAR right now!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Should be a SimpleXMLElement structure</span></pre></div></div>

<p>The status was updated, but with no source. A short debug and look through the source revealed that factory behavior (not passing the current options to the newly instantiated statuses object). I don&#8217;t really see the rationale behind this, so I filed a <a href="http://pear.php.net/bugs/bug.php?id=15472" target="_blank">bug report</a>.</p>
<p>What <em>did</em> work, was instantiating a Twitter_Statuses object, and working with it directly, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">&quot;Services/Twitter/Statuses.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Services_Twitter_Statuses<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOptions</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'source'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'myapp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I'm coding with PEAR right now!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now you can Tweet away with source!</p>
]]></content:encoded>
			<wfw:commentRss>http://orensol.com/2009/01/13/pears-services_twitter-and-the-source-option/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
