<?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>Made of Everything You&#039;re Not &#187; twitter api</title>
	<atom:link href="http://blog.ericlamb.net/tag/twitter-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ericlamb.net</link>
	<description>Thoughts on programming, people and life</description>
	<lastBuildDate>Thu, 27 Oct 2011 01:29:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Simple Twitter Search with PHP</title>
		<link>http://blog.ericlamb.net/2009/05/simple-twitter-search-with-php/</link>
		<comments>http://blog.ericlamb.net/2009/05/simple-twitter-search-with-php/#comments</comments>
		<pubDate>Thu, 14 May 2009 13:30:48 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHPTwitterSearch]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=1642</guid>
		<description><![CDATA[So, I&#8217;ve already gone into detail on the Arc90 Twitter API Service and it&#8217;s pretty fun to work with. One small problem though; it&#8217;s pretty big, complicated and, well, bulky. There&#8217;s a lot you have to do to get something up and running. Enter PHPTwitterSearch; a pretty easy to use, lightweight, Twitter API Search class. [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve already gone into detail on the <a href="http://blog.ericlamb.net/2009/04/arc90-twitter-api-service-part-1/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F04%2Farc90-twitter-api-service-part-1%2F','Arc90+Twitter+API+Service')">Arc90 Twitter API Service</a> and it&#8217;s pretty fun to work with. One small problem though; it&#8217;s pretty big, complicated and, well, bulky. There&#8217;s a lot you have to do to get something up and running.</p>
<div id="attachment_1643" class="wp-caption aligncenter" style="width: 186px"><a href="http://xkcd.com/574/" onclick="return TrackClick('http%3A%2F%2Fxkcd.com%2F574%2F','XKCD')" target="_blank"><img src="http://blog.ericlamb.net/wp-content/uploads/2009/05/swine_flu-176x300.png" alt="XKCD" title="XKCD" width="176" height="300" class="size-medium wp-image-1643" /></a><p class="wp-caption-text">XKCD</p></div>
<p>Enter <a href="http://ryanfaerman.com/twittersearch" onclick="return TrackClick('http%3A%2F%2Fryanfaerman.com%2Ftwittersearch','PHPTwitterSearch')" title="PHPTwitterSearch" target="_blank">PHPTwitterSearch</a>; a pretty easy to use, lightweight, Twitter API Search class. It&#8217;s based on the class originally developed by <a href="http://twitter.slawcup.com/twitter.class.phps" onclick="return TrackClick('http%3A%2F%2Ftwitter.slawcup.com%2Ftwitter.class.phps','David+Billingham')" title="David Billingham" target="_blank">David Billingham</a>, which I admit, I didn&#8217;t check out so I don&#8217;t know how much it&#8217;s based on.</p>
<p>The thing I didn&#8217;t really like about the Arc90 script was how complicated the search process was. In case you didn&#8217;t notice, I didn&#8217;t go into any detail about the search process; for precisely because it was just to complicated. I stopped having fun when working with the search functionality.</p>
<p>Simplicity was what immediately drew me to PHPTwitterSearch. Here&#8217;s a basic example of a search:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'findme'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SWTwitterSearch<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterSearch<span style="color: #000;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$search</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Very, very simple. The above searches the API for $query. </p>
<p>Here&#8217;s the best part though; for a little more complication all you have to do is chain the calls together.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SWTwitterSearch<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterSearch<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$search</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">with</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'hashtag'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">to</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'username2'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The above searches the API for tweets from &#8220;username&#8221; with the hash string &#8220;#hashtag&#8221; that was sent to the user &#8220;username2&#8243;. </p>
<p>The class returns an array with objects that&#8217;s really basic and simple. </p>
<div><a class="addthis_button" href="http://blog.ericlamb.net//addthis.com/bookmark.php?v=250" addthis:url='http://blog.ericlamb.net/2009/05/simple-twitter-search-with-php/' addthis:title='Simple Twitter Search with PHP '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/05/simple-twitter-search-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arc90 Twitter API Service Part 2</title>
		<link>http://blog.ericlamb.net/2009/05/arc90-twitter-api-service-part-2/</link>
		<comments>http://blog.ericlamb.net/2009/05/arc90-twitter-api-service-part-2/#comments</comments>
		<pubDate>Wed, 06 May 2009 13:59:58 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=1547</guid>
		<description><![CDATA[As promised, here&#8217;s the follow up to Arc90 Twitter API Service Part 1. If you haven&#8217;t read that piece yet you probably should&#8230; Here are the rest of the methods for interacting with Twitter via the Arc90 Twitter API Service. It should be noted that nearly everything in the below is taken from the generously [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here&#8217;s the follow up to <a href="http://blog.ericlamb.net/2009/04/arc90-twitter-api-service-part-1/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F04%2Farc90-twitter-api-service-part-1%2F','Arc90+Twitter+API+Service+Part+1')" title="Arc90 Twitter API Service Part 1">Arc90 Twitter API Service Part 1</a>. If you haven&#8217;t read that piece yet you probably should&#8230;</p>
<div id="attachment_1527" class="wp-caption aligncenter" style="width: 165px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/04/twitter_logo_header.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F04%2Ftwitter_logo_header.png','Twitter')"><img src="http://blog.ericlamb.net/wp-content/uploads/2009/04/twitter_logo_header.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F04%2Ftwitter_logo_header.png','Twitter')" alt="Twitter" title="Twitter" width="155" height="36" class="size-full wp-image-1527" /></a><p class="wp-caption-text">Twitter</p></div>
<p>Here are the rest of the methods for interacting with Twitter via the <a href="http://lab.arc90.com/2008/06/php_twitter_api_client.php" onclick="return TrackClick('http%3A%2F%2Flab.arc90.com%2F2008%2F06%2Fphp_twitter_api_client.php','Arc90+Twitter+API+Service')" title="Arc90 Twitter API Service" target="_blank">Arc90 Twitter API Service</a>.</p>
<p>It should be noted that nearly everything in the below is taken from the generously documented source code.</p>
<h3>Get Messages</h3>
<p>Returns a list of the 20 most recent direct messages sent to the authenticating user. The XML and JSON versions include detailed information about the sending and recipient users. This method can return XML< JSON, ATOM and RSS.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
$params['page'] = '0';
$params['since'] = mktime(date(&quot;H&quot;)-4, date(&quot;i&quot;), date(&quot;s&quot;)); //unix timestamp;
$params['since_id'] = '0';
*/</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessages</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Sent Messages</h3>
<p>Returns a list of the 20 most recent direct messages sent by the authenticating user.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
$params['page'] = '0';
$params['since'] = mktime(date(&quot;H&quot;)-4, date(&quot;i&quot;), date(&quot;s&quot;)); //unix timestamp;
$params['since_id'] = '0';
*/</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSentMessages</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$format</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Send Message</h3>
<p>Sends a new direct message to the specified user from the authenticating user. This shows up under their &#8220;Direct Messages&#8221; section.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Hello from my script!'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'USER_TO_SEND_TO'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//can be username or user_id</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sendMessage</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Destroy Message</h3>
<p>Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_OF_MESSAGE_TO_DELETE'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">destroyMessage</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Create Friendship</h3>
<p>Befriends the user specified in the ID parameter as the authenticating user. Returns the befriended user in the requested format when successful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_OF_USER_TO_BEFRIEND'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createFriendship</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Destroy Friendship</h3>
<p>Discontinues friendship with the user specified in the ID parameter as the authenticating user.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_OF_USER_TO_DESTROY_FRIEND'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">destroyFriendship</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Check if Friendship Exists</h3>
<p>Tests if a friendship exists between two users.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$user_a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'USER_1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user_b</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'USER_2'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">friendshipExists</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$user_a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user_b</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Location</h3>
<p>Updates the location attribute of the authenticating user, as displayed on the side of their profile and returned in various API methods. Please note this is not normalized, geocoded, or translated to latitude/longitude at this time.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$location</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Home'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateLocation</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$location</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Delivery Device</h3>
<p>Sets which device Twitter delivers updates to for the authenticating user. $device Must be one of: sms, im, none.</p>
<p>Sending &#8216;none&#8217; as the device parameter will disable IM or SMS updates.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$device</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'sms'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateDeliveryDevice</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$device</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Profile Colors</h3>
<p>Sets one or more hex values that control the color scheme of the authenticating user&#8217;s profile page on twitter.com. These values are also returned in the /users/show API method.</p>
<p>At least one of the $params is required.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'profile_background_color'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#FFFFFF'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'profile_text_color'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#000000'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'profile_link_color'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#CCCCCC'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'profile_sidebar_fill_color'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#999999'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'profile_sidebar_border_color'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#FFFFFF'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateProfileColors</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Profile Image</h3>
<p>Updates the authenticating user&#8217;s profile image. Image must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/path/to/image/'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Local file path of the image to be uploaded</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateProfileImage</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Profile Background Image</h3>
<p>Updates the authenticating user&#8217;s profile background image. Image must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be scaled down.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/path/to/image/'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Local file path of the image to be uploaded</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateProfileBackgroundImage</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Profile</h3>
<p>Sets values that users are able to set under the &#8220;Account&#8221; tab of their settings page. Only the parameters specified will be updated; to only update the &#8220;name&#8221; attribute, for example, only include that parameter in your request.</p>
<p>At least one of the $params is required.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Name_TO_Use'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Email_To_Use'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'URL_TO_Use'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'location'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Location_TO_Use'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Description_TO_Use'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateProfile</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Favorites</h3>
<p>Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//The ID or screen name of the user for whom to request a list of favorite statuses.</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFavorites</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Create Favorite</h3>
<p>Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The ID of the status to favorite</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createFavorite</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Destroy Favorite</h3>
<p>Un-favorites the status specified in the ID parameter as the authenticating user. Returns the un-favorited status in the requested format when successful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The ID of the status to favorite</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">destroyFavorite</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Follow</h3>
<p>Enables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.</p>
<p>NOTE: The Notification Methods require the authenticated user to already be friends with the specified user. Otherwise the error &#8220;there was a problem following the specified user&#8221; will be returned.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The ID or screen name of the user to follow</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">follow</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Leave</h3>
<p>Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.</p>
<p>NOTE: The Notification Methods require the authenticated user to already be friends with the specified user. Otherwise the error &#8220;there was a problem following the specified user&#8221; will be returned.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The ID or screen name of the user to leave</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">leave</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Block</h3>
<p>Blocks the user specified in the ID parameter as the authenticating user. Returns the blocked user in the requested format when successful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The ID or screen name of the user to block</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">block</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Un-Block</h3>
<p>Un-blocks the user specified in the ID parameter as the authenticating user. Returns the un-blocked user in the requested format when successful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The ID or screen name of the user to block</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">unblock</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Graph Friends</h3>
<p>Returns an array of numeric IDs for every user the specified user is following.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ID or screen_name of the user to retrieve the friends ID list for</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">graphFriends</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Graph Followers</h3>
<p>Returns an array of numeric IDs for every user the specified user is followed by.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_TO_Use'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//ID or screen_name of the user to retrieve the followers ID list for</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">graphFollowers</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$format</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<div><a class="addthis_button" href="http://blog.ericlamb.net//addthis.com/bookmark.php?v=250" addthis:url='http://blog.ericlamb.net/2009/05/arc90-twitter-api-service-part-2/' addthis:title='Arc90 Twitter API Service Part 2 '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/05/arc90-twitter-api-service-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arc90 Twitter API Service Part 1</title>
		<link>http://blog.ericlamb.net/2009/04/arc90-twitter-api-service-part-1/</link>
		<comments>http://blog.ericlamb.net/2009/04/arc90-twitter-api-service-part-1/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 13:21:32 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=1511</guid>
		<description><![CDATA[Twitter is all the rage these days; everyone&#8217;s on it and everyone seems to love it. Not me, of  course. Like most social networking tools and services I find the whole thing pretty stupid. And, again, I&#8217;m apparently wrong because I&#8217;ve done some digging into manipulating the Twitter API so I can use it on [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Twitter" href="http://twitter.com/" onclick="return TrackClick('http%3A%2F%2Ftwitter.com%2F','Twitter')" target="_blank">Twitter</a> is all the rage these days; everyone&#8217;s on it and everyone seems to love it. Not me, of  course. Like most social networking tools and services I find the whole thing pretty stupid.</p>
<div id="attachment_1527" class="wp-caption aligncenter" style="width: 165px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/04/twitter_logo_header.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F04%2Ftwitter_logo_header.png','Twitter')"><img class="size-full wp-image-1527" title="Twitter" src="http://blog.ericlamb.net/wp-content/uploads/2009/04/twitter_logo_header.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F04%2Ftwitter_logo_header.png','Twitter')" alt="Twitter" width="155" height="36" /></a><p class="wp-caption-text">Twitter</p></div>
<p>And, again, I&#8217;m apparently wrong because I&#8217;ve done some digging into manipulating the <a title="Twitter API" href="http://apiwiki.twitter.com/" onclick="return TrackClick('http%3A%2F%2Fapiwiki.twitter.com%2F','Twitter+API')" target="_blank">Twitter API</a> so I can use it on my client&#8217;s sites.</p>
<p>There are a few <a title="Twitter API Libraries" href="http://apiwiki.twitter.com/Libraries" onclick="return TrackClick('http%3A%2F%2Fapiwiki.twitter.com%2FLibraries','Twitter+API+Libraries')" target="_blank">different libraries</a> available for accessing the API, in all the popular programming languages, but the one I chose was the <a title="PHP Twitter API Client" href="http://lab.arc90.com/2008/06/php_twitter_api_client.php" onclick="return TrackClick('http%3A%2F%2Flab.arc90.com%2F2008%2F06%2Fphp_twitter_api_client.php','PHP+Twitter+API+Client')" target="_blank">PHP Twitter API Client</a>. Unlike all the other php libraries available this one has <em>sick </em><a title="PHP Twitter API Client Documentation" href="http://www.arc90.com/_assets/Arc90_Service_Twitter/docs/" onclick="return TrackClick('http%3A%2F%2Fwww.arc90.com%2F_assets%2FArc90_Service_Twitter%2Fdocs%2F','PHP+Twitter+API+Client+Documentation')" target="_blank">documentation</a>. We&#8217;re talking full phpdocumentor documentation; pure geak porn here.</p>
<p>I wanted to document the client but it&#8217;s a really, REALLY, exhaustive codeset so I&#8217;m going to break it up into 2 different posts. </p>
<h3>The Basics</h3>
<p>The Arc90 API client requires the entire library be in the php include path so you&#8217;ll have to either modify the php.ini directly or use <a title="ini_set" href="http://us3.php.net/manual/en/function.ini-set.php" onclick="return TrackClick('http%3A%2F%2Fus3.php.net%2Fmanual%2Fen%2Ffunction.ini-set.php','ini_set')" target="_blank">ini_set</a> to include the library. Kinda sucks, but whatever.</p>
<p>The client can also return the response in a few different data formats: XML, JSON and sometimes even RSS and ATOM depending on how you call the API and whether that format is available. For the purposes of this article all the examples will be returned in JSON format.</p>
<p>In order for the client to work you  have to have <a title="CURL" href="http://us3.php.net/curl" onclick="return TrackClick('http%3A%2F%2Fus3.php.net%2Fcurl','CURL')" target="_blank">CURL</a> installed and available to php. Most hosts already do but you never know so it&#8217;s best to check with your host if you&#8217;re not sure.</p>
<p>It&#8217;s also important to familiarize yourself with all the ins and outs of the Twitter API. They employ <a title="Rate Limiting" href="http://apiwiki.twitter.com/Rate-limiting" onclick="return TrackClick('http%3A%2F%2Fapiwiki.twitter.com%2FRate-limiting','Rate+Limiting')" target="_blank">rate limiting</a> and have some useful <a title="Getting Started with the Twitter API" href="http://apiwiki.twitter.com/Getting-Started" onclick="return TrackClick('http%3A%2F%2Fapiwiki.twitter.com%2FGetting-Started','Getting+Started+with+the+Twitter+API')" target="_blank">information for developers</a> that&#8217;ll help make the API a little less painful.</p>
<h3>Basic Example</h3>
<p>The client is a full OOP service with exceptions so the basic layout of the algorithm is like the below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//echo ini_get('include_path');</span>
<span style="color: #22f;">require_once</span> <span style="color: #0000ff;">'Arc90/Service/Twitter.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'YOUR_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;
<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Arc90_Service_Twitter<span style="color: #000;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
try
<span style="color: #000;">&#123;</span> 
&nbsp;
	<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFriendsTimeline</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// If Twitter returned an error (401, 503, etc), print status code</span>
	<span style="color: #22f;">if</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isError</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span>
	<span style="color: #000;">&#123;</span>
		<span style="color: #22f;">echo</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">http_code</span><span style="color: #339933;">;</span>
	<span style="color: #000;">&#125;</span>
	<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000;">&#125;</span>
catch<span style="color: #000;">&#40;</span>Arc90_Service_Twitter_Exception <span style="color: #000088;">$e</span><span style="color: #000;">&#41;</span>
<span style="color: #000;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Print the exception message (invalid parameter, etc)</span>
	<span style="color: #22f;">print</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>For all additional examples I&#8217;ll only be displaying exactly what&#8217;s necessary; take that into account.</p>
<h3>End Session</h3>
<p>Ends the session of the authenticating user, returning a null cookie. Use this method to sign users out of client-facing applications like widgets.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">endSession</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Public Timeline</h3>
<p>Returns the 20 most recent statuses from non-protected users who have set a custom user icon. This method can return  JSON, XML, ATOM and RSS.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPublicTimeline</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Friends Timeline</h3>
<p>Returns the 20 most recent statuses posted by the authenticating user and that user&#8217;s friends. This method can return  JSON, XML, ATOM and RSS.</p>
<p>If the optional $params are passed you can pare down the results.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'since'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #000;">&#40;</span><span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;H&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;i&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//unix timestamp</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'since_id'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'POST_ID_TO_USE_SINCE'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//id of post</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'10'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//must be &lt; 200</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFriendsTimeline</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span><span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get User Timeline</h3>
<p>Returns the most recent statuses posted from the authenticating user based on the set options. This method can return  JSON, XML, ATOM and RSS.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'since'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #000;">&#40;</span><span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;H&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;i&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//unix timestamp</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_OF_USER_TO_CHECK'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//id of user to look up</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'since_id'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'902529454'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//id of post</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'10'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//must be &lt; 200</span>
<span style="color: #000088;">$params</span><span style="color: #000;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUserTimeline</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span><span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Show Status</h3>
<p>Returns the status for a single user based on the provided id. This method can return XML and JSON.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">showStatus</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'ID_OF_USER_TO_CHECK'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Update Status</h3>
<p>Updates the authenticating user&#8217;s status and returns the posted status in the requested format when successful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'My Script Sent This Status'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateStatus</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span> <span style="color: #000088;">$in_reply_to_status_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Replies</h3>
<p>Returns the 20 most recent @replies (status updates prefixed with @username) for the authenticating user. Returns JSON, XML, ATOM and RSS.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
$params['page'] = '0';
$params['since'] = mktime(date(&quot;H&quot;)-4, date(&quot;i&quot;), date(&quot;s&quot;)); //unix timestamp 4 hours ago;
$params['since_id'] = '0';
*/</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getReplies</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Destroy Status</h3>
<p>Destroys the status specified by the required ID parameter. The authenticating user must be the author of the specified status.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ID_OF_STATUS_TO_DESTROY'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">destroyStatus</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Friends</h3>
<p>Returns the 20 most recent statuses from non-protected users who have set a custom user icon. This method can return ATOM and RSS.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
$params['id'] = 'ID_OF_USER_TO_GET_FRIENDS_FOR'; 
$params['page'] = '0';
$params['since'] = mktime(date(&quot;H&quot;)-4, date(&quot;i&quot;), date(&quot;s&quot;)); //unix timestamp;
$params['lite'] = TRUE; //removes status
*/</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFriends</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Get Followers</h3>
<p>Returns the authenticating user&#8217;s followers, each with current status inline. They are ordered by the order in which they joined Twitter (this is going to be changed). This method can return ATOM and RSS.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
$params['id'] = 'ID_OF_USER_TO_GET_FRIENDS_FOR'; 
$params['page'] = '0';
$params['lite'] = TRUE; //removes status
*/</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFollowers</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$params</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Show User</h3>
<p>According to the source code on this method:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Returns extended information for a given user, specified by ID, screen name, or email.
 *
 * This information includes design settings, so third party developers can theme their widgets
 * according to a given user's preferences.
 * 
 * You must be properly authenticated to request the page of a protected user.
 *
 * The API allows a user to be identified by ID, screen name, or email.
 * Any of these fields may be provided using the $id parameter.
 *
 * A user ID must be passed as an integer.
 * A screen name or an email address must be passed as a string.
 *
 * Show data for a user with an ID of 123: showUser(123)
 * Show data for a user with a screen name of 123: showUser(&quot;123&quot;)
 */</span></pre></td></tr></table></div>

<p>Can return in XML or JSON.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'SCREEN_NAME_ID_OR_EMAIL_OF_USER_TO_CHECK'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">showUser</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'json'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Print the XML response</span>
<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">json_decode</span><span style="color: #000;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Be sure to check out <a href="http://blog.ericlamb.net/2009/05/arc90-twitter-api-service-part-2/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F05%2Farc90-twitter-api-service-part-2%2F','Arc90+Twitter+API+Service+Part+2')" title="Arc90 Twitter API Service Part 2">Part 2 of the series</a> for details on the remaining methods and functionality.</p>
<div><a class="addthis_button" href="http://blog.ericlamb.net//addthis.com/bookmark.php?v=250" addthis:url='http://blog.ericlamb.net/2009/04/arc90-twitter-api-service-part-1/' addthis:title='Arc90 Twitter API Service Part 1 '><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/04/arc90-twitter-api-service-part-1/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

