<?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>Steve Reynolds Blog &#187; API</title>
	<atom:link href="http://www.reynoldsftw.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reynoldsftw.com</link>
	<description>Being Generalist.</description>
	<lastBuildDate>Wed, 28 Jul 2010 20:36:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone OS 4.0 &#8211; No Beta 5 &#8211; WWDC update?</title>
		<link>http://www.reynoldsftw.com/2010/06/iphone-os-4-0-no-beta-5-wwdc-update/</link>
		<comments>http://www.reynoldsftw.com/2010/06/iphone-os-4-0-no-beta-5-wwdc-update/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 09:02:58 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[iPhone 4.0]]></category>
		<category><![CDATA[iPhone HD]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=1824</guid>
		<description><![CDATA[
			
				
			
		
Last night Apple missed their fortnightly update to the iPhone OS 4.0 beta program. Apple has managed to hit this schedule for the past 2 months since the announcement of 4.0. Earlier yesterday I speculated around whether or not we would see an update:
&#8220;I wonder if Apple will hold back another beta for iPhone OS [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F06%2Fiphone-os-4-0-no-beta-5-wwdc-update%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F06%2Fiphone-os-4-0-no-beta-5-wwdc-update%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Last night Apple missed their fortnightly update to the iPhone OS 4.0 beta program. Apple has managed to hit this schedule for the past 2 months since the announcement of 4.0. Earlier <a href="http://twitter.com/SteveReynolds/status/15162497167" target="_blank">yesterday I speculated</a> around whether or not we would see an update:</p>
<p style="text-align: center;"><span style="color: #000000;"><em>&#8220;I wonder if Apple will hold back another beta for iPhone OS today and release at WWDC to intro new hardware APIs?&#8221;</em></span></p>
<p>I may be completely wrong on this one, but let&#8217;s look at the facts (ahem rumours). Apple are probably 95% going to launch the <em><strong>&#8216;iPhone HD&#8217;</strong></em> or whatever they want to call it at <strong>WWDC</strong> next week. Based on the lovely <em>Gizmodo</em> leak, the device has a front facing camera. John Gruber has also speculated (and various rumours appear to confirm) that the device will also house a &#8220;HD&#8221; screen.</p>
<p>Both of those would require software/API changes to utilize. Firstly, the front facing camera would require an update to the iPhone <em>UIImagePickerController</em> API which currently enables applications to hook into the camera on the back to capture image and video. Somehow, Apple would need to change that so you can select which camera you want to use front or back &#8211; perhaps both?? Who knows?</p>
<p>Potentially though, Apple could release the new hardware without having the front facing camera accessible through developer APIs at this stage. It&#8217;s unlikely, but could happen.</p>
<p>In addition to this, the new <em>&#8216;HD screen&#8217;</em> has the potential impact on 3rd party applications. Unknown yet is how Apple would scale up current standard definition applications for previous iPhone devices. They could use the iPad method of scaling up, however as a developer I&#8217;m really concerned by that approach, as in many cases it turns out pretty ugly.</p>
<p>More likely is<strong> XCode</strong> and <strong>Interface Builder</strong> are updated to support this new resolution, so you can rebuild your app&#8217;s UI. Perhaps going forward we will build to the new resolution, and the older phones will scale down? That&#8217;s certainly my preference&#8230;</p>
<p>Anyway, suffice to say with WWDC being 1 week away it seems logical that Apple would hold back any update to iPhone 4.0 beta until Monday 7th June. After all, there are potentially other software additions for the new device that go beyond just hardware that have the potential to have APIs. It would make sense to have all of that <em>&#8220;available now&#8221;</em>, as Jobs finishes his keynote.</p>
<p><em><strong>More importantly though, let&#8217;s hope that &#8216;iPhone HD&#8217; is available now.</strong></em>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F06%2Fiphone-os-4-0-no-beta-5-wwdc-update%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F06%2Fiphone-os-4-0-no-beta-5-wwdc-update%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2010/06/iphone-os-4-0-no-beta-5-wwdc-update/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Twitter API calls in the browser with JSON and jQuery</title>
		<link>http://www.reynoldsftw.com/2009/12/twitter-api-calls-in-the-browser-with-json-and-jquery/</link>
		<comments>http://www.reynoldsftw.com/2009/12/twitter-api-calls-in-the-browser-with-json-and-jquery/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 13:00:43 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JSONP]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=1617</guid>
		<description><![CDATA[
			
				
			
		
Ajax is a wonderful technology that is heavily used in many places nowdays. Ajax is run in the browser using javascript to call a URL, and usually receive data back. One of the key restrictions of using Ajax to get data from a remote URL is that you cannot make cross-domain calls. This meaning, you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F12%2Ftwitter-api-calls-in-the-browser-with-json-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F12%2Ftwitter-api-calls-in-the-browser-with-json-and-jquery%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Ajax is a wonderful technology that is heavily used in many places nowdays. Ajax is run in the browser using javascript to call a URL, and usually receive data back. One of the key restrictions of using Ajax to get data from a remote URL is that you cannot make cross-domain calls. This meaning, you cannot make an ajax call to domain1.com from domain2.com because of browser security restrictions. The workaround, is to make the cross domain ajax calls from your web server rather than the browser, and all is fine!</p>
<p>That was, until the introduction of JSON, and more importantly JSONP which allows you to make ajax calls to 3rd party domains from within the browser itself. What this means for you is that you can get data from JSONP supported APIs from within the browser itself, rather than telling your web server to do it for you.</p>
<p><span id="more-1617"></span><img class="aligncenter size-full wp-image-953" title="twitter" src="http://www.reynoldsftw.com/wp-content/uploads/2009/03/twitter.jpg" alt="twitter" width="374" height="100" /></p>
<p>This is also important for <strong>Twitter API</strong> usage. One of the key restrictions with the Twitter API is that any client IP address can only make x number of API calls per hour. If you&#8217;re making these API calls from your web server (which obviously only a static IP address), you could quickly use up your hourly allocation on a busy site. Twitter does allow you to &#8220;whitelist&#8221; your web application to give you a better hourly rate, but here&#8217;s a better way:</p>
<p>Use the clients, ie your users, to make the API calls from their browsers.</p>
<p>Admittedly, my example below is for any API calls that do not require authentication, however what it does enable you to do is to empower your user to make Twitter API calls in the browser using jQuery. So without further ado, here&#8217;s the code snippet:</p>
<pre class="brush: jscript;">$.getJSON(&quot;http://twitter.com/statuses/user_timeline.json?screen_name=SteveReynolds&amp;callback=?&quot;,

function(data){

$.each(data, function(i,item){
$(&quot;#tweets&quot;).append(item.text + &quot;&lt;BR/&gt;&quot;);

});

});
</pre>
<p>What the code above assumes is that you have a &lt;div id=&#8221;tweets&#8221;&gt; or something where you can append the results, in this case the object in the JSON response &#8220;item.text&#8221; which is the tweet itself. You could for example, get &#8220;item.user.name&#8221; which would return the username for each tweet (which is useless as you know it&#8217;s all my tweets <img src='http://www.reynoldsftw.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) &#8211; but you get the idea. You also need to make sure you have previously called the jQuery library.</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-6415056921376217";
google_ad_channel = "in-ad-unit-hor";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "";
google_color_url = "0066CC";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
<p>The other important factor of the code above is the URL we are using to call Twitter. We have appended &#8220;&amp;callback=?&#8221; onto the end of it. This is to allow the jQuery call to pass the returned data to a callback function, which in this case is simply called &#8220;data&#8221; for the returned data, and &#8220;function()&#8221; for the callback.</p>
<p><a href="http://www.reynoldsftw.com/wp-content/uploads/2009/12/twitter.html.zip" target="_self">Download the code here</a>.</p>
<p>So, that&#8217;s it. It really is that simple. In my next tutorial I will show you how to do the above, but ajax it back to your server and save it to your database &#8211; in effect getting your users to do a lot of the hard work for you in the browser, and simply sending back the relevant results to your database.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F12%2Ftwitter-api-calls-in-the-browser-with-json-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F12%2Ftwitter-api-calls-in-the-browser-with-json-and-jquery%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2009/12/twitter-api-calls-in-the-browser-with-json-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending Authenticated Data to the Twitter API</title>
		<link>http://www.reynoldsftw.com/2009/02/sending-authenticated-data-to-the-twitter-api/</link>
		<comments>http://www.reynoldsftw.com/2009/02/sending-authenticated-data-to-the-twitter-api/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 08:30:36 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=472</guid>
		<description><![CDATA[
			
				
			
		
In my previous jQuery tutorial I discussed how you can authenticate against the Twitter API to retrieve personal data. However, what we didn&#8217;t do is show you how to POST data back to Twitter, like tweeting. It&#8217;s actually very simple, and can be done by quickly updating your cURL script in PHP.
cURL POSTFIELDS
&#60;?php

$username = &#34;yourusername&#34;;
$password [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fsending-authenticated-data-to-the-twitter-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fsending-authenticated-data-to-the-twitter-api%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In my <a href="http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/" target="_self">previous jQuery tutorial</a> I discussed how you can authenticate against the Twitter API to retrieve personal data. However, what we didn&#8217;t do is show you how to POST data back to Twitter, like tweeting. It&#8217;s actually very simple, and can be done by quickly updating your cURL script in PHP.</p>
<h3>cURL POSTFIELDS</h3>
<pre class="brush: php;">&lt;?php

$username = &quot;yourusername&quot;;
$password = &quot;yourpassword&quot;;
$twitterHost = &quot;http://twitter.com/statuses/update.xml&quot;;
$yourStatus = &quot;Hello - I am Tweeting from my custom script!&quot;;
$curl;

$curl = curl_init();

curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, &quot;$username:$password&quot;);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_POSTFIELDS, &quot;status=&quot;. urlencode(stripslashes(urldecode($yourStatus))));
curl_setopt($curl, CURLOPT_URL, $twitterHost);

$result = curl_exec($curl);
$resultArray = curl_getinfo($curl);

if ($resultArray['http_code'] == 200) {

echo &quot;Success!&quot;

} else {

echo &quot;We have failed... oh no!&quot;;

}
curl_close($curl);

?&gt;</pre>
<p>This script is very very similar to <a href="http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/" target="_blank">the last one</a> we discussed. All we have changed is the Twitter API url, and added an additional cURL statement to add POSTFIELDS to the cURL call. Very lovely!</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-6415056921376217";
google_ad_channel = "in-ad-unit-hor";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "";
google_color_url = "0066CC";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
<h3>Conclusion</h3>
<p>That just about wraps up my 3 part tutorial on how to work with the Twitter API with PHP and jQuery. I hope you enjoyed the set, and please feel free to add your own feedback and comments below.</p>
<h3>Further Reading on this topic&#8230;</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<thead></thead>
<tbody>
<tr>
<td align="center" valign="top">
<div id="attachment_475" class="wp-caption aligncenter" style="width: 111px"><a href="http://www.amazon.com/gp/product/0596154615?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596154615"><img class="size-full wp-image-475" title="Developing the Twitter API" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/twitter-api.jpg" alt="Developing the Twitter API" width="101" height="132" /></a><p class="wp-caption-text">Developing the Twitter API</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=0596154615" border="0" alt="" width="1" height="1" /></td>
<td align="center" valign="top">
<div id="attachment_476" class="wp-caption aligncenter" style="width: 111px"><a href="http://www.amazon.com/gp/product/B001AV5BJS?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B001AV5BJS"><img class="size-full wp-image-476" title="Practical Web2.0 with PHP" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/practical-web-20.jpg" alt="Practical Web2.0 with PHP" width="101" height="132" /></a><p class="wp-caption-text">Practical Web2.0 with PHP</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=B001AV5BJS" border="0" alt="" width="1" height="1" /></td>
<td align="center" valign="top">
<div id="attachment_477" class="wp-caption aligncenter" style="width: 111px"><a href="http://www.amazon.com/gp/product/0672329166?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0672329166"><img class="size-full wp-image-477" title="PHP Web Development" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/php-web-development.jpg" alt="PHP Web Development" width="101" height="132" /></a><p class="wp-caption-text">PHP Web Development</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=0672329166" border="0" alt="" width="1" height="1" /></td>
</tr>
</tbody>
</table>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fsending-authenticated-data-to-the-twitter-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fsending-authenticated-data-to-the-twitter-api%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2009/02/sending-authenticated-data-to-the-twitter-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Authenticating Twitter API calls with PHP &amp; jQuery</title>
		<link>http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/</link>
		<comments>http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 08:00:04 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Social-Web]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=380</guid>
		<description><![CDATA[
			
				
			
		
 
In my previous post on this subject I spoke about making a simple call to the Twitter Search API to return some results every 30 seconds using jQuery and ajax. This time over I am going to discuss a similar process, however this time our API calls are authenticated with our Twitter credentials (to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fauthenticating-twitter-api-calls-with-php-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fauthenticating-twitter-api-calls-with-php-and-jquery%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<div style="float: left; margin-right: 5px;"><script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script> </div>
<p>In my <a href="http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/" target="_self">previous post</a> on this subject I spoke about making a simple call to the Twitter Search API to return some results every 30 seconds using jQuery and ajax. This time over I am going to discuss a similar process, however this time our API calls are authenticated with our Twitter credentials (to return your favorites in this example). So here goes&#8230;</p>
<h3>PHP and cURL</h3>
<p>Again I am going to use PHP with cURL to communicate with the Twitter API as well as return the XML. Here&#8217;s the code &#8211; create it in a file called getFavorites.php :</p>
<pre class="brush: php;">&lt;?php

$username = &quot;yourusername&quot;;
$password = &quot;yourpassword&quot;;
$twitterHost = &quot;http://twitter.com/favorites.xml&quot;;
$curl;

$curl = curl_init();

curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, &quot;$username:$password&quot;);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_URL, $twitterHost);

$result = curl_exec($curl);
curl_close($curl);

header('Content-Type: application/xml; charset=ISO-8859-1');

print $result;

?&gt;</pre>
<p>There&#8217;s alot here, the key parts being the first 3 variables, your username &amp; password, and the API url. There are alot of cURL bits involved here, I won&#8217;t go into them, but you can read more about <a href="http://uk3.php.net/curl" target="_blank">them here</a>.</p>
<h3>The jQuery</h3>
<p>The jQuery part is actually pretty similar to <a href="http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/" target="_self">my last article</a>, all we&#8217;re going to do is change the XML node names for this particular API call&#8230; Create this in a file called controller.js :</p>
<pre class="brush: jscript;">$(document).ready(function() {

getFavorites();

});

function getFavorites()
{
var results;

$.get(&quot;/getFavorites.php&quot;,  function(xml){
$('status',xml).each(function(i){
var title = $(this).find(&quot;text&quot;).text();
results = title + &quot;&lt;BR&gt;&quot;;
});
$(&quot;#container&quot;).html(results);
});

}
</pre>
<p>All I have really changed is to iterate through each &lt;status&gt; node, and get each &lt;text&gt; child node from that. The &lt;text&gt; node holds the text of your favorite tweets. We&#8217;re also posting the results to a #container DIV again.</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-6415056921376217";
google_ad_channel = "in-ad-unit-sq";
google_ui_features = "rc:0";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "";
google_color_url = "0066CC";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
<h3>The HTML</h3>
<p>This is actually exactly the same as the <a href="http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/" target="_self">last tutorial</a>, but i&#8217;ll re-post it here just for fun! <img src='http://www.reynoldsftw.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: xml;">&lt;HTML&gt;
&lt;HEAD&gt;
&lt;script src=&quot;http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;controller.js&quot;&gt;&lt;/script&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;

&lt;DIV id=&quot;container&quot;&gt;&lt;/DIV&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
<p>There we go &#8211; done! Authenticating successfully to the Twitter API via PHP, with our jQuery happily rendering the XML returned via a GET ajax call and posting it back to our HTML document. The jQuery involvement is very loose in this example, as it really actually isn&#8217;t needed &#8211; but you get the idea on how you can integrate the ajax calls and build on up form there to do really cool things!</p>
<p>As always, <a href="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jquery-php-twitter-api-authenticated.zip" target="_blank">here is the code</a> to download to try it yourself <img src='http://www.reynoldsftw.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<thead>
<h3>Tools to help you learn:</h3>
</thead>
<tbody>
<tr>
<td width="33%" align="center" valign="top">
<div id="attachment_425" class="wp-caption alignnone" style="width: 111px"><a href="http://www.amazon.com/gp/product/1847192505?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847192505"><img class="size-full wp-image-425" title="Learning jQuery" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/learningjquery.jpg" alt="Learning jQuery" width="101" height="132" /></a><p class="wp-caption-text">Learning jQuery</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=1847192505" border="0" alt="" width="1" height="1" /></td>
<td width="33%" align="center" valign="top">
<div id="attachment_770" class="wp-caption aligncenter" style="width: 111px"><a href="http://www.amazon.com/gp/product/B00154JDAI?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B00154JDAI"><img class="size-full wp-image-770" title="kindle" src="http://www.reynoldsftw.com/wp-content/uploads/2009/03/kindle.jpg" alt="Amazon Kindle 2" width="101" height="132" /></a><p class="wp-caption-text">Amazon Kindle 2</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=B00154JDAI" border="0" alt="" width="1" height="1" /></td>
<td width="33%" align="center" valign="top">
<div id="attachment_426" class="wp-caption alignnone" style="width: 111px"><a href="http://www.amazon.com/gp/product/1847193811?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847193811"><img class="size-full wp-image-426" title="jQuery Reference Guide" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jqueryreferenceguide.jpg" alt="jQuery Reference Guide" width="101" height="132" /></a><p class="wp-caption-text">jQuery Reference Guide</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=1847193811" border="0" alt="" width="1" height="1" /></td>
</tr>
</tbody>
</table>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fauthenticating-twitter-api-calls-with-php-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fauthenticating-twitter-api-calls-with-php-and-jquery%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>jQuery &#8211; PHP &amp; Ajax with the Twitter API</title>
		<link>http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/</link>
		<comments>http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 13:40:06 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Effectiveness]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=328</guid>
		<description><![CDATA[
			
				
			
		
So for today&#8217;s blog post I am going to show you how you can use jQuery, PHP and a little ajax to connect up to the Twitter API and return results. I&#8217;ll cover off unauthenticated calls today to the search API, and follow up with the authenticated piece a little later, so watch out for [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fusing-jquery-php-ajax-with-the-twitter-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fusing-jquery-php-ajax-with-the-twitter-api%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>So for today&#8217;s blog post I am going to show you how you can use jQuery, PHP and a little ajax to connect up to the Twitter API and return results. I&#8217;ll cover off unauthenticated calls today to the <a href="http://apiwiki.twitter.com/Search+API+Documentation" target="_blank">search API</a>, and follow up with the <a href="http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/" target="_self">authenticated piece a little later</a>, so watch out for that!</p>
<h3>PHP using cURL</h3>
<p>So, in order for us to talk to the Twitter API, we need to use cURL. This isn&#8217;t a hard and fast rule, but it sure does make our lives easier. The cURL library should be installed as part of your PHP installation, but do check.</p>
<p>cURL allows us to make a simple call to the Twitter API, and grab some results back if necessary. I&#8217;ll be using XML to return results for this demo, but you can use JSON if you want. Anyway, without further ado, here is a nice piece of PHP code to talk to the <a href="http://apiwiki.twitter.com/Search+API+Documentation" target="_blank">Twitter Search API</a> &#8211; so create a file called getSearch.php :</p>
<pre class="brush: php;">&lt;?php

$query = $_POST['query'];

$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, &quot;http://search.twitter.com/search.atom?q=&quot; . urlencode($query) . &quot;&amp;amp;amp;amp;rpp=10&quot;);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec ($curl);
curl_close ($curl);

header('Content-Type: application/xml; charset=ISO-8859-1');

print $result;
?&gt;
</pre>
<p>So, lets quickly explain this. The PHP script will take POST data, in this case a query, and send the query to the Twitter Search API. The Twitter API is also taking an rpp parameter, which is the number of results to be returned. It will then return XML, and also print it out as a valid XML document. Job done. Obviously there is no error handling, this is the bare bones &#8211; I will let you deal with all of that!</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-6415056921376217";
google_ad_channel = "in-ad-unit-sq";
google_ui_features = "rc:0";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "";
google_color_url = "0066CC";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
<h3>The jQuery</h3>
<p>The jQuery side is also pretty straight forward&#8230; It&#8217;ll do an ajax post call to our PHP script, and go through the XML returned and paste it into a location in your DOM HTML. So, create a controller.js file and put this code into it:</p>
<pre class="brush: jscript;">var timer;

$(document).ready(function() {

getSearch();

});

function getSearch()
{
clearTimeout(timer);
var results;
var theQuery = &quot;stevereynolds&quot;;

$.post(&quot;/getSearch.php&quot;, {query: theQuery},  function(xml){
$('entry',xml).each(function(i){
var title = $(this).find(&quot;title&quot;).text();
results = title + &quot;&lt;BR&gt;&quot;;
});
$(&quot;#container&quot;).html(results);
});

timer = setTimeout('getSearch()', 30000);
}
</pre>
<p>So this code sets the query parameter to &#8220;stevereynolds&#8221;, makes an ajax post to our getSearch.php file, and then runs through the returned XML. It firstly searches for the &#8220;entry&#8221; node, and then the &#8220;title&#8221; parameter as part of each &#8220;entry&#8221; node in the XML. Lastly, it applies the results to a container in your DOM called &#8220;container&#8221;. This function also runs every 30 seconds, see the setTimeout for that part.</p>
<h3>Putting it all together</h3>
<p>So, putting it together is pretty darn easy. Create an HTML page in the same directory as all of the above, with the following:</p>
<pre class="brush: xml;">&lt;HTML&gt;
&lt;HEAD&gt;
&lt;script src=&quot;jquery-1.3.1.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;controller.js&quot;&gt;&lt;/script&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;

&lt;DIV id=&quot;container&quot;&gt;&lt;/DIV&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
<p>Thats it! When you load your HTML it will call the controller.js -&gt; which in turn will call the javascript function getSearch() to return <a href="http://apiwiki.twitter.com/Search+API+Documentation" target="_blank">Twitter Search API</a> results every 30 seconds.</p>
<p><a href="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jquery-php-twitter-api.zip"><img class="alignleft size-full wp-image-86" title="Download Icon" src="http://www.reynoldsftw.com/wp-content/uploads/2009/01/drop-box-icon.png" alt="Download Icon" width="60" height="60" /></a>Feel free to <a href="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jquery-php-twitter-api.zip" target="_blank">download this code</a> and reuse as you want. As I said, it&#8217;s very simplistic &#8211; so go ahead and adapt this with lots more jQuery lovelyness! Feel free to share back your fine work! Also see my <a href="http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/" target="_self">new article</a> discussing making <a href="http://www.reynoldsftw.com/2009/02/authenticating-twitter-api-calls-with-php-and-jquery/" target="_self">authenticated calls to the Twitter API</a>.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<thead>
<h3>Further Reading:</h3>
</thead>
<tbody>
<tr>
<td width="33%" align="center" valign="top">
<div id="attachment_425" class="wp-caption alignnone" style="width: 111px"><a href="http://www.amazon.com/gp/product/1847192505?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847192505"><img class="size-full wp-image-425" title="Learning jQuery" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/learningjquery.jpg" alt="Learning jQuery" width="101" height="132" /></a><p class="wp-caption-text">Learning jQuery</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=1847192505" border="0" alt="" width="1" height="1" /></td>
<td width="33%" align="center" valign="top">
<div id="attachment_770" class="wp-caption aligncenter" style="width: 111px"><a href="http://www.amazon.com/gp/product/B00154JDAI?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B00154JDAI"><img class="size-full wp-image-770" title="kindle" src="http://www.reynoldsftw.com/wp-content/uploads/2009/03/kindle.jpg" alt="Amazon Kindle 2" width="101" height="132" /></a><p class="wp-caption-text">Amazon Kindle 2</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=B00154JDAI" border="0" alt="" width="1" height="1" /></td>
<td width="33%" align="center" valign="top">
<div id="attachment_426" class="wp-caption alignnone" style="width: 111px"><a href="http://www.amazon.com/gp/product/1847193811?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847193811"><img class="size-full wp-image-426" title="jQuery Reference Guide" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jqueryreferenceguide.jpg" alt="jQuery Reference Guide" width="101" height="132" /></a><p class="wp-caption-text">jQuery Reference Guide</p></div>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=1847193811" border="0" alt="" width="1" height="1" /></td>
</tr>
</tbody>
</table>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fusing-jquery-php-ajax-with-the-twitter-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F02%2Fusing-jquery-php-ajax-with-the-twitter-api%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/feed/</wfw:commentRss>
		<slash:comments>79</slash:comments>
		</item>
		<item>
		<title>Twitters 20,000 API limit</title>
		<link>http://www.reynoldsftw.com/2009/01/twitters-20000-api-limit/</link>
		<comments>http://www.reynoldsftw.com/2009/01/twitters-20000-api-limit/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 09:37:33 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=146</guid>
		<description><![CDATA[
			
				
			
		
Scary news out of Twitter HQ this week, they&#8217;re limiting their API access for whitelisted application to 20,000 calls per hour! This is very bad news for developers of 3rd party applications, especially if they planned on the masses embracing their apps.



The requests are restricted to an IP/User, so I guess we have 2 scenarios

Application [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F01%2Ftwitters-20000-api-limit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F01%2Ftwitters-20000-api-limit%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Scary news out of Twitter HQ this week, they&#8217;re limiting their API access for whitelisted application to 20,000 calls per hour! This is very bad news for developers of 3rd party applications, especially if they planned on the masses embracing their apps.</p>
<p><center><script type="text/javascript"><!--
google_ad_client = "pub-6415056921376217";
google_ad_channel = "in-ad-unit-hor";
google_ui_features = "rc:0";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "";
google_color_url = "0066CC";

//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center></p>
<p>The requests are restricted to an IP/User, so I guess we have 2 scenarios</p>
<ol>
<li>Application is on a device (iPhone / PC)</li>
<li>Application is on the web</li>
</ol>
<p>I imagine device applications would be ok. Clients are restricted to 100 API calls per hour though, but all the API calls would be coming from different IP addresses.</p>
<p>Web applications are likely going to be a different story. What if all your API requests come directly from your one web server? 2000 users * 10 requests in an hour isn&#8217;t much! Especially if your application is aggregating data in the background which also uses the API.</p>
<p>Twitter really need to focus on this limitation, and try and give developers more. They&#8217;re struggling to monetise the site as it is, so restricting 3rd parties from using their product isn&#8217;t an ideal scenario for your potential future paying customers.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F01%2Ftwitters-20000-api-limit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2009%2F01%2Ftwitters-20000-api-limit%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2009/01/twitters-20000-api-limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

