<?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>Webmaster-Source &#187; api</title>
	<atom:link href="https://www.webmaster-source.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Thu, 24 Aug 2017 02:01:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Random User Generator</title>
		<link>https://www.webmaster-source.com/2013/08/21/random-user-generator/</link>
		<comments>https://www.webmaster-source.com/2013/08/21/random-user-generator/#comments</comments>
		<pubDate>Wed, 21 Aug 2013 11:26:58 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Services and Tools]]></category>
		<category><![CDATA[api]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=5161</guid>
		<description><![CDATA[RandomUser is a new API that returns a JSON object with a randomly generated persona—complete with name, avatar and email address—for your testing purposes. The site suggests using it for design mockups, but the fact that it&#8217;s an API opens up plenty of possibilities for more programmatic uses. If you need to fill in a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://randomuser.me/">RandomUser</a> is a new API that returns a JSON object with a randomly generated persona—complete with name, avatar and email address—for your testing purposes. The site suggests using it for design mockups, but the fact that it&#8217;s an API opens up plenty of possibilities for more programmatic uses. If you need to fill in a couple dozen users to test an application, you could write a script to populate the database with ones pulled from RandomUser.</p>
<p style="text-align: center;"><a href="http://randomuser.me/"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-5162 imgborder" alt="RandomUser" src="//www.webmaster-source.com/wp-content/uploads/2013/08/randomuser.png" width="600" height="364" /></a></p>
<p>The API is neat, but a little limited so far. Hopefully it will be expanded in the future with some additional info.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2013/08/21/random-user-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom JavaScript Twitter Widgets in an API 1.1 World</title>
		<link>https://www.webmaster-source.com/2013/07/03/custom-javascript-twitter-widgets-in-an-api-1-1-world/</link>
		<comments>https://www.webmaster-source.com/2013/07/03/custom-javascript-twitter-widgets-in-an-api-1-1-world/#comments</comments>
		<pubDate>Wed, 03 Jul 2013 11:46:27 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=5131</guid>
		<description><![CDATA[Continuing their gradual shutdown of old APIs (following the launch of version 1.1 of their API), Twitter recently pulled the plug on their old-style widgets and the unauthenticated search API. This means if you had a fancy custom-designed JavaScript widget to show off your latest tweets, it&#8217;s not going to work anymore. The only officially [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://matt.harzewski.com/"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-5132" alt="My Twitter Widget" src="//www.webmaster-source.com/wp-content/uploads/2013/06/mvhtwitterwidget.png" width="200" height="382" /></a>Continuing their gradual shutdown of old APIs (following the launch of version 1.1 of their API), Twitter recently pulled the plug on their old-style widgets and the unauthenticated search API. This means if you had a fancy custom-designed JavaScript widget to show off your latest tweets, it&#8217;s not going to work anymore. The only officially supported options are the <a href="https://twitter.com/settings/widgets">new widgets</a> or a server-side solution with OAuth authentication.</p>
<p>What can you do if you don&#8217;t like either option?</p>
<p><a href="http://jasonmayes.com/projects/twitterApi/">Jason Mayes</a> hacked together <a href="http://codepen.io/jasonmayes/pen/Ioype">a clever bit of JavaScript</a> that loads up one of the new Twitter widgets, scrapes the content out, and reformats it into nicer unstyled HTML. Then you can style it however you want in your stylesheet.</p>
<p>I&#8217;m using this right now on <a href="http://matt.harzewski.com/">my personal blog</a>, since Twitter&#8217;s new widgets don&#8217;t look very good when they&#8217;re crammed into a narrow sidebar.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2013/07/03/custom-javascript-twitter-widgets-in-an-api-1-1-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post to Twitter From a PHP Script: 2013 Edition</title>
		<link>https://www.webmaster-source.com/2013/01/09/post-to-twitter-from-a-php-script-2013-edition/</link>
		<comments>https://www.webmaster-source.com/2013/01/09/post-to-twitter-from-a-php-script-2013-edition/#comments</comments>
		<pubDate>Wed, 09 Jan 2013 11:18:20 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4956</guid>
		<description><![CDATA[Back in 2009, I wrote a post on how to write a simple PHP script to call on the Twitter API and update your status. Despite its popularity, the information hasn&#8217;t been relevant in some time. (Things certainly have changed since then!) The Twitter API has changed a lot over the years, and it&#8217;s not [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Back in 2009, <a href="http://www.webmaster-source.com/2009/04/05/post-to-twitter-from-a-php-script/">I wrote a post</a> on how to write a simple PHP script to call on the Twitter API and update your status. Despite its popularity, the information hasn&#8217;t been relevant in some time. (Things certainly have changed since then!) The Twitter API has changed a lot over the years, and it&#8217;s not so simple that you can get a newbie up and running with a few lines of code.</p>
<p>The mandatory usage of OAuth tokens, rather than a simple username and password combination, for API requests has greatly strengthened account security, but it&#8217;s one of the prime hurdles complicating the process. More recently, XML support was removed in favor of JSON, URL structures changed to include an API version, and authentication is now required for every request.</p>
<p>Fortunately, you don&#8217;t <em>have</em> to deal with the little details. You can use a library that does the heavy lifting for you, rather than reinventing the wheel. Sure, there are resources to learn how to do it the hard way, but I assume that you want a quicker solution if you&#8217;re reading this.</p>
<h3>Step 1: Download tmhOAuth</h3>
<p>Download the tmhOAuth library <a href="https://github.com/themattharris/tmhOAuth">from GitHub</a>. This package will handle interactions with the Twitter API once you include it from your script. (It requires at least PHP 5.1.2 and the cURL extension.)</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4957" alt="Download tmhOAuth" src="//www.webmaster-source.com/wp-content/uploads/2012/12/post2twitter-tmhoauth.jpg" width="596" height="213" /></p>
<p><span id="more-4956"></span></p>
<h3>Step 2: Include the Library in Your Project</h3>
<p>First, drop the required files into your project folder. You could simply move the entire download in and rename it, or if you just want the essentials, the required files are <code>tmhOAuth.php</code> and <code>cacert.pem</code>.</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4958 imgborder" alt="Including tmhOauth" src="//www.webmaster-source.com/wp-content/uploads/2012/12/post2twitter-dirstructure.png" width="600" height="140" /></p>
<p>Now, you need to include the files in your PHP script. All you need is an include line at the top.</p>
<pre class="brush: php; title: ; notranslate">
include 'tmhOAuth/tmhOAuth.php';
</pre>
<h3>Step 3: Get Your Tokens</h3>
<p>We need to make a short detour, now. In order to give your script permission to update your status, you need to generate some authorization tokens for it. Head over to <a href="http://dev.twitter.com/apps">dev.twitter.com/apps</a> and log in to your Twitter account.</p>
<p>Click the big &#8220;Create a new application&#8221; button and fill in the required fields on the resulting screen. All you need is an application name to identify your script, a brief description, and the URL it will reside at.</p>
<p>Once you agree to the terms of service and submit the form, select the Settings tab on the resulting screen. Change the access type from Read Only to Read and Write before saving the settings.</p>
<p>Flipping back to the Details tab, you now need to scroll down to the OAuth settings section. You will need the consumer key and consumer secret, as well as the access token and access secret from the following section.</p>
<p>After the include lines, you need to instantiate the tmhOAuth class with the tokens, like so:</p>
<pre class="brush: php; title: ; notranslate">
$tmhOAuth = new tmhOAuth(array(
  'consumer_key' =&gt; 'THE_CONSUMER_KEY',
  'consumer_secret' =&gt; 'THE_CONSUMER_SECRET',
  'token' =&gt; 'THE_ACCESS_TOKEN',
  'secret' =&gt; 'THE_ACCESS_TOKEN_SECRET',
));
</pre>
<p>This readies tmhOAuth to interact with the API through your account. (Allowing <em>other</em> Twitter users to log in and grant permission is beyond the scope of this tutorial. But <a href="http://net.tutsplus.com/tutorials/php/creating-a-twitter-oauth-application/">Tuts+ has you covered</a> if you want a more advanced tutorial.)</p>
<h3>Step 4: Sending the Tweet</h3>
<p>To send a tweet, all you have to do now is call the <code>request</code> method and pass the required arguments.</p>
<pre class="brush: php; title: ; notranslate">
$response = $tmhOAuth-&gt;request('POST', $tmhOAuth-&gt;url('1.1/statuses/update'), array(
  'status' =&gt; 'Test message. Lorem ipsum.'
));
</pre>
<p>You can, of course, replace the message with anything you want (providing it&#8217;s under 140 characters) and even use a dynamic variable instead of a static string.</p>
<h3>Step 5: Verify Success</h3>
<p>Now let&#8217;s see if Twitter accepted the request and successfully updated your status.</p>
<pre class="brush: php; title: ; notranslate">
if ($response != 200) {
	//Do something if the request was unsuccessful
	echo 'There was an error posting the message.';
}
</pre>
<h3>Conclusion</h3>
<p>That wasn&#8217;t too difficult, was it? While it&#8217;s a simple example, it should help you get started in the right direction. The tmhOAuth library can handle just about any Twitter API request you may need to make, and the GitHub repository includes plenty of examples to browse through.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2013/01/09/post-to-twitter-from-a-php-script-2013-edition/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Twitter API Terms Revision Ignites Controversy</title>
		<link>https://www.webmaster-source.com/2012/08/21/twitter-api-terms-revision-ignites-controversy/</link>
		<comments>https://www.webmaster-source.com/2012/08/21/twitter-api-terms-revision-ignites-controversy/#comments</comments>
		<pubDate>Tue, 21 Aug 2012 11:50:09 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4810</guid>
		<description><![CDATA[Twitter recently announced the next version of the REST API that powers the many apps that hook into the popular social media service, a move which sparked much criticism among users and developers alike. Some of the changes include: Every API endpoint will require authentication, through OAth Rate limiting is done per endpoint The revised [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-thumbnail wp-image-4811" title="Twitter Logo" src="//www.webmaster-source.com/wp-content/uploads/2012/08/twitter-bird-whitebg-75x75.png" alt="" width="75" height="75" />Twitter recently <a href="https://dev.twitter.com/blog/changes-coming-to-twitter-api">announced the next version</a> of the REST API that powers the many apps that hook into the popular social media service, a move which sparked much criticism among users and developers alike. Some of the changes include:</p>
<ul>
<li>Every API endpoint will require authentication, through OAth</li>
<li>Rate limiting is done per endpoint</li>
<li>The revised display guidelines will be more actively enforced. They want a more uniform style.</li>
<li>Developers will have to &#8220;work with Twitter&#8221; if they have more than an arbitrary number of users. As an app developer, you will need &#8220;[Twitter&#8217;s] permission if your application will require more than 100,000 individual user tokens.&#8221; Applications that already have over 100,000 tokens will have their fuzzy limit set at 200% of their current token count.</li>
</ul>
<p>The last point, especially, has been controversial, as it seems suspiciously like a ploy to disadvantage third-party Twitter clients and push users toward the official app. Whether that is the case or not, it could conceivably inconvenience the developers of popular apps like Tweetbot and Echofon.</p>
<blockquote class="twitter-tweet" width="500"><p>The sky is not falling, I’d obviously prefer that there wasn’t any cap, but the current cap is pretty huge and we aren’t going anywhere.</p>
<p>&mdash; Paul Haddad (@tapbot_paul) <a href="https://twitter.com/tapbot_paul/status/236238901340147712" data-datetime="2012-08-16T23:11:57+00:00">August 16, 2012</a></p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>Hopefully things will work out okay. Twitter&#8217;s own app is utterly mediocre in comparison to the better third-party clients, chiefly Tweetbot. Twitter would be shooting themselves in the foot if they put the kibosh on the software that some of the more influential users prefer. Third-party clients are what made Twitter what it is today, after all.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2012/08/21/twitter-api-terms-revision-ignites-controversy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Accepting Credit Cards Online With Stripe</title>
		<link>https://www.webmaster-source.com/2012/06/28/accepting-credit-cards-online-with-stripe/</link>
		<comments>https://www.webmaster-source.com/2012/06/28/accepting-credit-cards-online-with-stripe/#comments</comments>
		<pubDate>Thu, 28 Jun 2012 11:01:43 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Services and Tools]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[payment gateways]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4726</guid>
		<description><![CDATA[Historically, processing monetary transactions online has been a major pain. Conniving financial institutions would force you to pay tons of extra fees, requiring merchant accounts and other junk. Then Stripe came along, bringing some sanity to the e-commerce world. With Stripe, you get a no-hassle API and minimal fees. 2.9% + 30 cents, payed out [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="https://stripe.com/"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-4727" title="Stripe" src="//www.webmaster-source.com/wp-content/uploads/2012/06/stripe.png" alt="" width="185" height="185" /></a>Historically, processing monetary transactions online has been a major pain. Conniving financial institutions would force you to pay tons of extra fees, requiring merchant accounts and other junk. Then <a href="https://stripe.com/">Stripe</a> came along, bringing some sanity to the e-commerce world.</p>
<p>With Stripe, you get a no-hassle API and minimal fees. 2.9% + 30 cents, payed out to any bank account. The only requirement is that you set up HTTPS for customers&#8217; safety. (Technically, there is one other thing that may be an issue: Stripe is only available to US merchants for the time being.)</p>
<p>Nettuts+ has an excellent tutorial on how to set up a Stripe account and process transactions through the API: <a href="http://net.tutsplus.com/tutorials/other/so-you-want-to-accept-credit-cards-online/">So You Want to Accept Credit Cards Online?</a></p>
<p>The most difficult part is probably purchasing an SSL certificate and setting your server up to use HTTPS. Some hosts sell certificates, and may be able to configure your server for you. If you&#8217;re on your own, though, <a href="https://www.rapidsslonline.com/">RapidSSL</a> seems to be a good option. (They&#8217;re affordable and on the trust list of most browsers.)</p>
<p><a href="http://net.tutsplus.com/tutorials/other/so-you-want-to-accept-credit-cards-online/">So You Want to Accept Credit Cards Online?</a> [Nettuts+]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2012/06/28/accepting-credit-cards-online-with-stripe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proxying Web APIs with NGINX</title>
		<link>https://www.webmaster-source.com/2012/06/18/proxying-web-apis-with-nginx/</link>
		<comments>https://www.webmaster-source.com/2012/06/18/proxying-web-apis-with-nginx/#comments</comments>
		<pubDate>Mon, 18 Jun 2012 11:15:51 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[NGINX]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4688</guid>
		<description><![CDATA[Here&#8217;s a cool thing I bet you didn&#8217;t know could be done with the NGINX server: proxying APIs from web services. Why would you want to do that? Well, for starters, you can avoid running into cross-domain scripting issues. Your client-side JavaScript can query an API that doesn&#8217;t offer JSON-P support, by having it pass [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-4689" title="NGINX" src="//www.webmaster-source.com/wp-content/uploads/2012/05/nginx.gif" alt="" width="150" height="50" />Here&#8217;s a cool thing I bet you didn&#8217;t know could be done with the <a href="http://nginx.org/">NGINX</a> server: proxying APIs from web services. Why would you want to do that? Well, for starters, you can avoid running into cross-domain scripting issues.</p>
<p>Your client-side JavaScript can query an API that doesn&#8217;t offer JSON-P support, by having it pass through your server first. You can even cache the results for awhile, so you don&#8217;t run into rate limit issues. And if JSON-P is a necessity, you can transform the API response from vanilla JSON to JSON-P by echoing some additional content into the request.</p>
<p>You can read how to do all this in <a href="http://www.gabrielweinberg.com/blog/2011/07/nginx-json-hacks.html">an informative blog post</a> by the founder of <a href="http://duckduckgo.com/">DuckDuckGo</a>. It&#8217;s pretty much a matter of adding a location block that uses the <code>proxy_pass</code> function to pass the request along.</p>
<p><a href="http://www.gabrielweinberg.com/blog/2011/07/nginx-json-hacks.html">nginx JSON hacks</a> [Gabriel Weinberg]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2012/06/18/proxying-web-apis-with-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building an iPhone App to Parse the Twitter API with NSXMLParser</title>
		<link>https://www.webmaster-source.com/2011/10/24/building-an-iphone-app-to-parse-the-twitter-api-with-nsxmlparser/</link>
		<comments>https://www.webmaster-source.com/2011/10/24/building-an-iphone-app-to-parse-the-twitter-api-with-nsxmlparser/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 11:20:58 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4362</guid>
		<description><![CDATA[iOS has a simple event-based XML parser built in, which makes it fairly easy to do less involved parsing operations without having to load up a third-party framework. This tutorial will show you how to build a simple iPhone application that will download an XML feed from Twitter containing a user&#8217;s tweets, and then display [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>iOS has a simple event-based XML parser built in, which makes it fairly easy to do less involved parsing operations without having to load up a third-party framework. This tutorial will show you how to build a simple iPhone application that will download an XML feed from Twitter containing a user&#8217;s tweets, and then display them with a pretty UI. (You could easily adapt this to parse other XML documents, such as RSS feeds.)</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4364 imgborder" title="Displaying data from a Twitter XML feed in iOS" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-example-fantasyfolder.jpg" alt="" width="600" height="306" /></p>
<h3><span id="more-4362"></span>Getting Started</h3>
<p>First, create a new View-based application. Give it a memorable name like &#8220;TwitterXML.&#8221;</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4365 imgborder" title="Creating a view-based application in Xcode" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-view-based-application.png" alt="" width="600" height="471" /></p>
<p>Now that you have a clean slate to work off, let&#8217;s rename some classes. I find Xcode&#8217;s default naming scheme a bit silly, with the way it prepends the project name to each file. I think the Application Delegate should be called, simply, <em>AppDelegate.m</em> instead of the needlessly long <em>TwitterXMLAppDelegate.m.</em> However, you can&#8217;t just rename the file to whatever your preference is, as that would break things.</p>
<p>You can rename a class project-wide, file and all, by using the Refactoring tool. You can call it up by right-clicking on the class name in the implementation file and choosing &#8220;Refactoring&#8221; from the resulting menu.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4366" title="Renaming classes with the Refactor tool" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-renaming-classes-with-refactor-tool.png" alt="" width="600" height="352" /></p>
<p>This renaming business is entirely optional as far as this tutorial goes, but it&#8217;s worth know how to do. Imagine if you made a typo in a class name and didn&#8217;t realize it until after you had already referenced it in a few places. It&#8217;s nice to have an automated fix.</p>
<h3>Setting Up the Header File</h3>
<p>Most of our code is going to go in the View controller, named <em>TweetViewController</em> in my case. Switch to the corresponding .h file and we can start setting up properties and whatnot.</p>
<p>First, we need to implement the NSXMLParserDelegate protocol so our class can respond to NSXMLParser delegate methods. This is easily done by adding <em>NSXMLParserDelegate</em> to the <em>@interface</em> line, like so:</p>
<pre class="brush: cpp; title: ; notranslate">
@interface TweetViewController : UIViewController &lt;NSXMLParserDelegate&gt; {
</pre>
<p>Now we need to declare some variables and other objects in the interface block. We need a string to hold the name of the Twitter user whose profile we will be accessing, a mutable array to hold the statuses we&#8217;ve pulled from the parser and a few that are used to hold data temporarily during the parsing process. Also, we need a few IBOutlets so we can update the View once we finish reading the XML data.</p>
<pre class="brush: cpp; title: ; notranslate">
@interface TweetViewController : UIViewController &lt;NSXMLParserDelegate&gt; {
NSString *twitterUser;
NSMutableArray *statuses;
NSString *currentElement;
NSMutableDictionary *currentElementData;
NSMutableString *currentElementString;
IBOutlet UIImageView *backgroundImage;
IBOutlet UILabel *tweetLabel;
IBOutlet UIImageView *avatar;
}
</pre>
<p>Of course, we need to make these objects into properties. This means adding a few property declarations after the interface block ends.</p>
<pre class="brush: cpp; title: ; notranslate">
@property (nonatomic, retain) NSString *twitterUser;
@property (nonatomic, retain) NSMutableArray *statuses;
@property (nonatomic, retain) NSString *currentElement;
@property (nonatomic, retain) NSMutableDictionary *currentElementData;
@property (nonatomic, retain) NSMutableString *currentElementString;
@property (nonatomic, retain) UIImageView *backgroundImage;
@property (nonatomic, retain) UILabel *tweetLabel;
@property (nonatomic, retain) UIImageView *avatar;
</pre>
<p>And then you need to synthesize them in the .m file by adding the following line right after the @implementation line:</p>
<pre class="brush: cpp; title: ; notranslate">
@synthesize twitterUser, statuses, currentElement, currentElementData, currentElementString, backgroundImage, tweetLabel, avatar;
</pre>
<p>Now that that&#8217;s out of the way, we can get to the interesting part.</p>
<h3>Setting Up the Parser</h3>
<p>The first method in the View controller is &lt;em&gt;viewDidLoad&lt;/em&gt;, which fires as soon as the View as loaded. (Subtle, isn&#8217;t it?) We will be putting our initialization stuff in there. Basically, we just need to ready our properties, set the Twitter username and start the parser.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)viewDidLoad {
[super viewDidLoad];
statuses = [[NSMutableArray alloc] init];
currentElement = [[NSString alloc] init];
currentElementData = [[NSMutableDictionary alloc] init];
currentElementString = [[NSMutableString alloc] init];
twitterUser = [NSString stringWithString:@&quot;collis&quot;];
[self parseXMLForUser:twitterUser];
}
</pre>
<p>After the first arrays and dictionaries are initialized, the <em>twitterUser</em> string is set to the username of the Twitter account we want the app to pull the latest statuses from. I&#8217;m using <a href="http://twitter.com/#!/collis">Collis</a>, one of the co-founders of <a href="http://envato.com/">Envato</a>, as an example. You could put any user you want there, so long as they have a cool-looking background on their profile!</p>
<p>The last line calls the <em>parseXMLForUser:</em> method and passes the <em>twitterUser</em> string along with it. We will work on that part next.</p>
<p>The <em>parseXMLForUser:</em> method is responsible for setting up the parser, as well as building the Twitter API URL.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parseXMLForUser:(NSString *)user {

//Build the Twitter API URL by combining the user with the rest of the URL
NSString *urlString = [NSString stringWithFormat:@&quot;http://twitter.com/statuses/user_timeline/%@.xml?count=3&quot;, user];
NSURL *url = [NSURL URLWithString:urlString];

//Create an instance of NSXMLParser and download the XML data from the URL
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];

//Set this class as its own delegate so we can process NSXMLParser callbacks
[parser setDelegate:self];

//Disable namespace support and other things we don't really need
[parser setShouldProcessNamespaces:NO];
[parser setShouldReportNamespacePrefixes:NO];
[parser setShouldResolveExternalEntities:NO];

[parser parse]; //Go go gadget XML parser...

[parser release];

}
</pre>
<p>The first part of the method should look familiar to anyone who has worked with C or Java before. It takes our <em>user</em> argument (which contains the text of <em>twitterUser</em>) and splices it into the URL string, just before the <em>.xml</em> part. Cocoa expects URLs to be of the NSURL object type, we create a new one of those and pass it <em>urlString</em>.</p>
<p>After that is done, we create a new instance of the NSXMLParser class and nickname it &#8220;parser.&#8221; We also pass it the new URL object, which it will use to download the contents it finds there at runtime. Next we set the parser&#8217;s delegate to <em>self</em>, or the current class. The next three lines turn off some features we don&#8217;t really need. Finally, we kick the parser into action and leave a <em>[parser release]</em> command to clean up after it&#8217;s done.</p>
<p>That was simple, wasn&#8217;t it? Sadly, that was only the beginning. In order for the parser to, well, <em>parse</em> we still need to implement the delegate methods for NSXMLParser. And we need to make a spiffy UI.</p>
<h3>Building the Parser</h3>
<p>NSXMLParser is what is called an event-based parser. This means it loops around, searching a document for anything that looks like an XML tag. When it finds one, it raises an event. Basically it says &#8220;I found an opening tag named &#8216;something'&#8221; and leaves you to deal with it. The parser does the same thing with ending tags and the text between them. We have to implement delegate methods to handle these events and save the data they find.</p>
<p>Let&#8217;s start with a couple of simple ones.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parserDidStartDocument:(NSXMLParser *)parser {
NSLog(@&quot;The XML document is now being parsed.&quot;);
}

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSLog(@&quot;Parse error: %d&quot;, [parseError code]);
}
</pre>
<p>The first method fires when NSXMLParser starts to parse the document. For this application, there isn&#8217;t really anything that we need to do at that point. Putting an NSLog there is great for debugging, though. (If your app is crashing, it&#8217;s helpful to know whether it&#8217;s getting to that step or not.) I&#8217;m sure you can guess what the <em>parseErrorOccurred</em> method does. (It logs an error code if the XML document is malformed or if, for some other reason, the parser could not process it.)</p>
<p>Moving on, we have a method that is called when the parser finds an opening XML tag.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {

//Store the name of the element currently being parsed.
currentElement = [elementName copy];

//Create an empty mutable string to hold the contents of elements
currentElementString = [NSMutableString stringWithString:@&quot;&quot;];

//Empty the dictionary if we're parsing a new status element
if ([elementName isEqualToString:@&quot;status&quot;]) {
[currentElementData removeAllObjects];
}

}
</pre>
<p>This one is a bit more complicated. When it&#8217;s called, its arguments are populated with information that the parser found out about the element currently being parsed. It&#8217;s name is what we care about, primarily. Using the properties we created earlier, the method keeps track of the element currently being parsed (we need to know its name in other methods) and whatever is <em>inside</em> the element (between the opening and closing tag). The conditional statement at the end empties our dictionary every time the parser moves on to a new &lt;status&gt; element, as we will have already copied its contents to the statuses array.</p>
<p>The next delegate method takes any characters found inside an XML element and stores it in the <em>currentElementString</em> property for later.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
//Take the string inside an element (e.g. &lt;tag&gt;string&lt;/tag&gt;) and save it in a property
[currentElementString appendString:string];
}
</pre>
<p>And finally, the penultimate method. This one contains the real meat of the parser. It is called whenever NSXMLParser comes across a closing XML tag. And so, it serves as a good place to put most of the data-saving logic.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

//If we've hit the &lt;/status&gt; tag, store the data in the statuses array
if ([elementName isEqualToString:@&quot;status&quot;]) {
[statuses addObject:[currentElementData copy]];
}

//Trim any extra spaces and newline characters from around currentElementString
NSString *string = [currentElementString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

//Store the status data in the currentElementData dictionary
if ([currentElement isEqualToString:@&quot;created_at&quot;]) {
[currentElementData setObject:string forKey:@&quot;created_at&quot;];
} else if ([currentElement isEqualToString:@&quot;text&quot;]) {
[currentElementData setObject:string forKey:@&quot;text&quot;];
} else if ([currentElement isEqualToString:@&quot;retweeted&quot;]) {
[currentElementData setObject:string forKey:@&quot;retweeted&quot;];
} else if ([currentElement isEqualToString:@&quot;id&quot;]) {
[currentElementData setObject:string forKey:@&quot;id&quot;];
} else if ([currentElement isEqualToString:@&quot;profile_image_url&quot;]) {
[currentElementData setObject:string forKey:@&quot;profile_image_url&quot;];
} else if ([currentElement isEqualToString:@&quot;profile_background_image_url&quot;]) {
[currentElementData setObject:string forKey:@&quot;profile_background_image_url&quot;];
} else if ([currentElement isEqualToString:@&quot;profile_link_color&quot;]) {
[currentElementData setObject:string forKey:@&quot;profile_link_color&quot;];
}

}
</pre>
<p>The first code chunk saves the contents of the <em>currentElementData</em> dictionary to the <em>statuses</em> array if, and only if, the ending tag being processed currently is &lt;/status&gt;. If you remember from before, <em>currentElementData</em> will be emptied the next time the <em>didStartElement</em> method is called. Otherwise, the block will be skipped and the application will handle the tasks it needs to run for child elements of &lt;status&gt;.</p>
<p>After stripping out extraneous spaces and newline characters from either side of <em>currentElementString</em>, so we don&#8217;t end up with weird output, we have a rather long if/else if block. This checks whether the element being parsed is one we want to save (e.g. &#8220;text&#8221; or &#8220;profile_image_url&#8221;) and if it is, it adds it to the element data dictionary.</p>
<p>The code may seem a bit strange at first, but it should make more sense after you become more familiar with it.</p>
<p>And now, for the last delegate method. This one fires when the document has finished parsing. This is the place to launch any operations we want to be started after we have our data. As you can see below, logging the <em>statuses</em> array to the console and then calling a method to display that data is what we will be doing here.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parserDidEndDocument:(NSXMLParser *)parser {
//Document has been parsed. It's time to fire some new methods off!
NSLog(@&quot;%@&quot;, statuses);
[self updateView];
}
</pre>
<h3>The View</h3>
<p>After all that code, let&#8217;s work on the interface. Double-click the <em>TweetViewController.xib</em> file (or whatever your View XIB is called) in the Xcode sidebar to open it in Interface Builder. Now that your screen is sufficiently cluttered with windows, you want to drag a UIImageView from the Library window into your View canvas. Make sure that it is sized to fit the whole available area.</p>
<p>Of course, the Image View won&#8217;t be much use to us unless we link it with the controller. Right-click on the File&#8217;s Owner icon and drag the little rubberband/wire thing from the <em>backgroundImage</em> Outlet over to the UIImageView and drop it. The File&#8217;s Owner overlay window should update to show the Image View as being connected to <em>backgroundImage</em>.</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4367 imgborder" title="Adding a UIImageView in Interface Builder" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-ib-adding-uiimageview.png" alt="" width="600" height="440" /></p>
<p>I think this app would be better if it used a horizontal orientation, don&#8217;t you? Click the little arrow icon in the upper right corner of the View canvas. Interface Builder should automagically resize the Image View inside it to still fill the View. Save the XIB file out and switch back to Xcode. Now we have to configure the application to use a landscape orientation instead of the default portrait one.</p>
<p>Inside your controller class there should be a method called <em>shouldAutorotateToInterfaceOrientation</em>. It&#8217;s commented out by default. Uncomment it and change the interfaceOrientation to <em>UIInterfaceOrientationLandscapeLeft</em>. It should look like this:</p>
<pre class="brush: cpp; title: ; notranslate">
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
</pre>
<p>Back in Interface Builder, drop in a new UIImageView. We won&#8217;t be hooking this one up to an IBOutlet. Instead, we will set the image to the word bubble image I made (it&#8217;s in the project file), resize the view to be the same point-width as the image (375&#215;208) and position it neatly over the background image view. I also lowered the opacity a bit, just because I liked the effect.</p>
<p>Now we need a way to display the contents of the latest tweet. So drag a UILabel onto the View canvas and resize it to fit nicely over the word bubble graphic. Turn the &#8220;# Lines&#8221; setting up to five or so, set the font size to something that looks legible and change the &#8220;Line Breaks&#8221; option to &#8220;Word Wrap. Then wire it up to the <em>tweetLabel</em> IBOutlet, like you did with the UIImageView.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4368" title="Adding the Label" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-adding-the-label.png" alt="" width="600" height="421" /></p>
<p>Ready to tie everything together? Switch back to Xcode and add one last method to the controller class.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)updateView {

//Select the latest tweet
NSDictionary *latestTweet = [statuses objectAtIndex:0];

//Set the tweet label
[tweetLabel setText:[latestTweet objectForKey:@&quot;text&quot;]];

//Set the background image after downloading it.
NSString *urlString = [latestTweet objectForKey:@&quot;profile_background_image_url&quot;];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *background = [[UIImage alloc] initWithData:data];
[backgroundImage setImage:background];
backgroundImage.contentMode = UIViewContentModeScaleAspectFill;

}
</pre>
<p>While it looks nearly as intimidating as the NSXMLParser <em>didEndElement</em> delegate method, it&#8217;s actually quite a bit simpler. The first line gets the newest tweet from the <em>statuses</em> array, the =<em>[tweetLabel setText:&#8230;]</em>= line updates the UILabel with the text of the message, and the last part changes the background image behind the word bubble to be the same as the Twitter user&#8217;s profile background.</p>
<p>That last part needs the most explanation. Before we can display the image (which is what the <em>setImage</em> line does) we have to download it first. Taking the <em>urlString</em>, which of course is a string containing the web address where the image can be found, we convert it to a NSURL object, which is named <em>url</em>. We create a new NSData object and use it&#8217;s <em>dataWithContentsOfURL</em> method to download the image. (Cocoa requires that URLs used with it&#8217;s objects be of the NSURL class.) Next we initialize a UIImage object with the NSData object and set it as the image in the UIImageView named backgroundImage. Oh, and we set the content mode to <em>UIViewContentModeScaleAspectFill</em> so it&#8217;s not squished funny.</p>
<p>Now if you build and run the app, you should get something like this:</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4369 imgborder" title="A styled tweet in the iOS app" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-first-demo-tweet-on-bg.png" alt="" width="600" height="394" /></p>
<p>Before we free up our allocated memory and finish the app up, let&#8217;s add one more thing: an avatar field! Switch back to Interface Builder and add a new UIImageView. Resize it to 52&#215;52 or so and wire it up to the &#8220;avatar&#8221; IBOutlet. Re-using the code from the background image bit, we can quickly modify it for the avatar.</p>
<pre class="brush: cpp; title: ; notranslate">
//Set the avatar image after downloading it.
NSString *avatarUrlString = [latestTweet objectForKey:@&quot;profile_image_url&quot;];
NSURL *avatarUrl = [NSURL URLWithString:avatarUrlString];
NSData *avatarData = [NSData dataWithContentsOfURL:avatarUrl];
UIImage *avatarImage = [[UIImage alloc] initWithData:avatarData];
[avatar setImage:avatarImage];
avatar.contentMode = UIViewContentModeScaleAspectFill;
</pre>
<p>That goes in the <em>updateView</em> method, after everything else.</p>
<p>Now, before we can say the application is finished, there is one thing that needs to be done. Any memory we specifically allocated should be released. It&#8217;s not a huge deal in a single-view app, as it will be forcefully freed up on exit, but it&#8217;s a good habit to get into. (In more complicated applications, you can expect to see frequent crashes if you don&#8217;t release objects when you&#8217;re done with them.) It&#8217;s easy to do. For every object we explicitely <em>alloc</em> or <em>retain</em>, we have to <em>release</em> somewhere. The <em>dealloc</em> method is called when the application quits in this case, so we put most of our <em>release</em> statements there.</p>
<p>You can learn more about iOS memory management in <a href="http://mobile.tutsplus.com/freebies/qa-sessions/qa-session-3-ios-memory-management-and-best-practices/">this screencast</a>.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)dealloc {
[twitterUser release];
[statuses release];
[currentElement release];
[currentElementData release];
[currentElementString release];
[backgroundImage release];
[tweetLabel release];
[avatar release];
[super dealloc];
}
</pre>
<p>And we&#8217;re done!</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4370 imgborder" title="And we're done!" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-final.png" alt="" width="505" height="342" /></p>
<h3>Additional Challenge</h3>
<p>Want to add to this sample application? Try making the following change: Use an <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html">NSTimer</a> to cycle through the items in the <em>statuses</em> array and update the View accordingly. Most of the groundwork has been laid for you already.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/10/24/building-an-iphone-app-to-parse-the-twitter-api-with-nsxmlparser/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Cache Data with the WordPress Transients API</title>
		<link>https://www.webmaster-source.com/2011/01/24/cache-data-with-the-wordpress-transients-api/</link>
		<comments>https://www.webmaster-source.com/2011/01/24/cache-data-with-the-wordpress-transients-api/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 11:41:51 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3808</guid>
		<description><![CDATA[WP Engineer had an interesting post recently about a WordPress &#8220;Transients API&#8221; that is used for caching bits of data temporarily. I often use the Options API to cache things from external servers, such as Twitter statuses, so I don&#8217;t hit Twitter&#8217;s servers more often than necessary (which would slow down page loads). The Transients [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>WP Engineer had an interesting post recently about a <a href="http://wpengineer.com/2148/simple-cache-with-the-wordpress-transient-api/">WordPress &#8220;Transients API&#8221;</a> that is used for caching bits of data temporarily. I often use the Options API to cache things from external servers, such as Twitter statuses, so I don&#8217;t hit Twitter&#8217;s servers more often than necessary (which would slow down page loads). The Transients API is similar, but with the addition of an expiration field. This makes it a much easier solution, even without its other added benefit.</p>
<blockquote><p>Also of note is that Transients are inherently sped up by caching  plugins, where normal options are not. A memcached plugin, for example,  would make WordPress store transient values in fast memory instead of in  the database. For this reason, transients should be used to store any  data that is expected to expire, or which can expire at any time.</p></blockquote>
<p>It&#8217;s simple enough to use the API. You just call the set_transient(), get_transient() and delete_transient() functions where appropriate. You can read up on the usage over at <a href="http://wpengineer.com/2148/simple-cache-with-the-wordpress-transient-api/">WP Engineer</a> or the <a href="http://codex.wordpress.org/Transients_API">WordPress Codex</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/01/24/cache-data-with-the-wordpress-transients-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate QR Codes On-the-Fly With the Google Chart API</title>
		<link>https://www.webmaster-source.com/2010/10/11/generate-qr-codes-on-the-fly-with-the-google-chart-api/</link>
		<comments>https://www.webmaster-source.com/2010/10/11/generate-qr-codes-on-the-fly-with-the-google-chart-api/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 11:14:48 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[(x)html]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[QR Codes]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3631</guid>
		<description><![CDATA[You&#8217;ve probably seen a QR code before, even if you didn&#8217;t know what it was at the time. It&#8217;s a little square matrix barcode that can be read by either a specialized scanner or a cellphone with the right software. UPS puts QR codes on their packages for tracking purposes, and many Android phones come [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://goo.gl/tIgD"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-3632" title="Download my 'Countdown Plus' app for the iPhone! :)" src="//www.webmaster-source.com/wp-content/uploads/qrcode-countdown-plus.png" alt="" width="150" height="150" /></a>You&#8217;ve probably seen a <a href="http://en.wikipedia.org/wiki/QR_Code">QR code</a> before, even if you didn&#8217;t know what it was at the time. It&#8217;s a little square matrix barcode that can be read by either a specialized scanner or a cellphone with the right software. UPS puts QR codes on their packages for tracking purposes, and many Android phones come with QR readers preinstalled for easily sharing links to apps.</p>
<p>A QR code can contain any sort of textual information, which will be decoded by a QR reader. A web address, a simple message, a phone number, etc.. A good QR reader should figure out what the decrypted data is and act upon it accordingly. If it&#8217;s a web address, it will display the web page. If it&#8217;s a phone number, it should display the number and offer to call it.</p>
<p>Users of the iPhone or fourth-generation iPod Touch can use a free app like <a href="http://itunes.apple.com/us/app/qr-code-reader-and-scanner/id388175979?mt=8">QR Reader</a> to scan QR codes.</p>
<p>What can you use a QR code for? There are plenty of possible applications. Magazines could print QR codes that let you quickly jump to a web page. (Anyone remember the <a href="http://en.wikipedia.org/wiki/CueCat">CueCat</a>?) Advertisements could have QR codes that offer more information. You could put a QR on your business card. Want to move a web page you&#8217;re reading from your computer to your phone? Create a quick QR matrix and scan it right off the screen!</p>
<p>Now for the fun part&#8230; How do you make your own QR codes?<span id="more-3631"></span></p>
<p>Google has a nifty <a href="http://code.google.com/apis/chart/">API for dynamically generating charts</a>. A simple (if messy-lookig) URL request will instantly generate an image containing a pie chart or a line graph. While QR codes aren&#8217;t exactly charts, the service has an option to generate them all the same. All you have to do is use a URL like this:</p>
<pre class="brush: plain; title: ; notranslate">http://chart.apis.google.com/chart?cht=qr&amp;chs=500x500&amp;choe=UTF-8&amp;chld=H&amp;chl=http://www.webmaster-source.com</pre>
<p>If you visit the above URL in your web browser, you should see a huge 500&#215;500 pixel QR code that will take you to Webmaster-Source if you scan it. You could easily copy and save the image, print it, or embed it in a web page by using the URL in an &lt;img&gt; tag.</p>
<p>The key/value parameters in the URL are as follows.</p>
<ul>
<li><strong>cht=qr</strong> — This tells the API that we&#8217;re creating a QR code instead of a pie chart or whatever.</li>
<li><strong>chs=500&#215;500</strong> — The size of the chart, in pixels. (I imagine &#8220;chs&#8221; stands for &#8220;CHart Size.&#8221;) 500&#215;500 seems to be the maximum size.</li>
<li><strong>choe=UTF-8</strong> — The content encoding. You should probably leave this as-is.</li>
<li><strong>chld=H</strong> — This seems to set the type of QR code. If you remove it, a different pattern will be used. I would recommend keeping the default unless you know what you&#8217;re doing.</li>
<li><strong>chl=[&#8230;]</strong> — The data you want to create a QR code for, such as a web address. If it is a URL, just paste it verbatim after the equality sign.</li>
</ul>
<p>The beauty of the API is it&#8217;s simplicity. If you know you&#8217;re building some sort of web app, you could <em>easily</em> use your language of choice to mash your data up into a URL request and spit out an image tag with a QR code. Google already does this with their Goo.gl URL shortener. If you look at one of their <a href="http://goo.gl/info/QMET">URL info pages</a>, it displays a small QR code and a link to a larger one. (Actually, adding &#8220;.qr&#8221; to the end of any Goo.gl URL will display the QR code.) It&#8217;s a very easy way to get a quick QR.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2010/10/11/generate-qr-codes-on-the-fly-with-the-google-chart-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Authenticating Users With Twitter OAuth</title>
		<link>https://www.webmaster-source.com/2010/08/06/authenticating-users-with-twitter-oauth/</link>
		<comments>https://www.webmaster-source.com/2010/08/06/authenticating-users-with-twitter-oauth/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 11:54:14 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3498</guid>
		<description><![CDATA[If you&#8217;ve ever played around with the Twitter API, you&#8217;ll know that many functions require authentication with either a username/password combination or OAuth. Soon Twitter will be turning off basic authentication for security reasons, in favor of the more complex OAuth protocol. There are plenty of benefits, for Twitter and for users and for developers, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;ve ever played around with the Twitter API, you&#8217;ll know that many functions require authentication with either a username/password combination or OAuth. Soon Twitter will be <a href="http://www.countdowntooauth.com/">turning off basic authentication</a> for security reasons, in favor of the more complex OAuth protocol. There are plenty of benefits, for Twitter and for users and for developers, but the transition will be a bit of a pain.</p>
<p>Fortunately, Net.Tuts+ has put together <a href="http://net.tutsplus.com/tutorials/php/how-to-authenticate-users-with-twitter-oauth/">a tutorial explaining how to implement OAuth authentication</a> in a Twitter application.</p>
<p>It&#8217;s a more complicated than it should be to implement the authentication dance (but it&#8217;s very easy for the end user, thankfully). There is one plus to using one of the Twitter OAuth libraries: it&#8217;s easier to handle API requests. Need to get a user timeline? If you&#8217;re already authenticated, you can just do this:</p>
<pre class="brush: php; title: ; notranslate">$nettuts_timeline = $twitteroauth-&gt;get('statuses/user_timeline', array('screen_name' =&gt; 'nettuts'));</pre>
<p>No worrying about cURL or file_get_contents(), the library&#8217;s classes take care of all of the boring stuff for you.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2010/08/06/authenticating-users-with-twitter-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-04-29 11:42:50 by W3 Total Cache
-->