<?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; twitter</title>
	<atom:link href="https://www.webmaster-source.com/tag/twitter/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>Why Twitter&#8217;s New &#8220;More Visual Tweets&#8221; Are a Bad Idea</title>
		<link>https://www.webmaster-source.com/2013/11/02/why-twitters-new-more-visual-tweets-are-a-bad-idea/</link>
		<comments>https://www.webmaster-source.com/2013/11/02/why-twitters-new-more-visual-tweets-are-a-bad-idea/#comments</comments>
		<pubDate>Sat, 02 Nov 2013 12:01:27 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=5232</guid>
		<description><![CDATA[Starting this week, your Twitter feed is going to look a lot different. In their infinite wisdom, the social media titan has decided that their media previews should now be expanded by default in their web interface and iOS app. (You can disable it in the iOS app, but not on the web.) So if [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Starting this week, your Twitter feed is going to look a lot different. In their infinite wisdom, the social media titan has decided that their <a href="https://blog.twitter.com/2013/picture-this-more-visual-tweets">media previews should now be expanded by default</a> in their web interface and iOS app. (You can disable it in the iOS app, but not on the web.) So if someone links to an image, you now get a Facebookesque image embedded in the tweet. Ditto for those silly looping videos from Vine.</p>
<p>I have a problem with this. A change, even one so deceptively small as this, can drastically alter how a social networking site is used.</p>
<p>Look at Facebook, for example. I don&#8217;t know about you, but my feed is an endless sea of images, with a rare plain-text status. It&#8217;s gotten to the point where if you want to say something and be heard, you have to set your text on a picture. Otherwise people will just scroll right past it, the visual noise drowning out the text. Photos, image macros and paragraphs of (frequently trite) text needlessly pasted into graphics that add next to nothing to the message.</p>
<p>Google+ has been even worse of late. If you join any of the &#8220;communities&#8221; Google recommends to you, even seemingly professional ones such as those for programming topics, you&#8217;re going to be seeing a lot of animated GIFs and image macros. (Or &#8220;internet cancer,&#8221; as I&#8217;ve heard them described: low-effort content that spreads across the Web, choking off interesting, insightful and informative content.)</p>
<p>I love words. I use Twitter because I want two things:</p>
<ol>
<li>A compact and scannable feed of short messages. The &#8220;stream of consciousness&#8221; that Twitter is famous for. Interesting things that don&#8217;t quite merit their own full-length blog posts.</li>
<li>Links to long form articles recommended by the people I follow.</li>
</ol>
<p>The addition of embedded media will be to the detriment of Twitter. It will encourage more image links and, potentially, tweets that solely consist of an image.</p>
<p>The change is already starting. On day one, I saw this:</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-5233" alt="What are you thinking, Harper Collins?" src="//www.webmaster-source.com/wp-content/uploads/2013/11/twitter-visual-yuck.png" width="495" height="611" /></p>
<p>I don&#8217;t even follow @HarperCollinsUK, it was retweeted, and I&#8217;m certainly not a C. S. Lewis fan. But here&#8217;s the same kind of junk, straight out of Facebook, showing up already. I guess it&#8217;s time to brace yourselves, because the image macros are coming.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-5234" alt="Image Macros are Coming" src="//www.webmaster-source.com/wp-content/uploads/2013/11/image-macros-stark.jpg" width="400" height="400" /></p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2013/11/02/why-twitters-new-more-visual-tweets-are-a-bad-idea/feed/</wfw:commentRss>
		<slash:comments>3</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>Adding Imgur Support to Tweetbot for Mac</title>
		<link>https://www.webmaster-source.com/2012/10/20/adding-imgur-support-to-tweetbot-for-mac/</link>
		<comments>https://www.webmaster-source.com/2012/10/20/adding-imgur-support-to-tweetbot-for-mac/#comments</comments>
		<pubDate>Sat, 20 Oct 2012 14:02:50 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Software & Scripts]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Tweetbot]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4876</guid>
		<description><![CDATA[The leading Twitter client for iOS just made its OS X debut on Thursday, and it has a very interesting feature. In the application&#8217;s preferences window, you can set the services that are used for URL shortening, image hosting, reading later, and so on. In addition to the usual suspects, you can choose &#8220;custom&#8221; as [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The leading Twitter client for iOS just made its OS X debut on Thursday, and it has a very interesting feature. In the application&#8217;s preferences window, you can set the services that are used for URL shortening, image hosting, reading later, and so on. In addition to the usual suspects, you can choose &#8220;custom&#8221; as an option for image uploads.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="//www.webmaster-source.com/wp-content/uploads/2012/10/tweetbot-upload-endpoint.png" alt="" title="Tweetbot custom upload endpoint" width="600" height="412" class="aligncenter size-full wp-image-4878 imgborder" /></p>
<p>Federico Viticci included <a href="http://www.macstories.net/news/tweetbot-for-mac-review/#mediauploads">a couple of PHP scripts</a> in his review that interface with the Tweetbot uploader and save the image to either Rackspace Files or your own server.</p>
<p>Well, I didn&#8217;t want to be left out of the fun, so I wrote one for <a href="http://imgur.com/">Imgur</a>, the supremely famous image host that grew out of Reddit&#8217;s habit of using up other image hosts&#8217; low per-image bandwidth allotments.<span id="more-4876"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
 
class TweetbotImgurEndpoint {
 
 
    private $api_key;
    private $api_url = &quot;https://api.imgur.com/3/upload.json&quot;;
    private $file_temp_location;
    private $file_name;
     
 
 
    function __construct($api_key, $file_temp_location, $file_name) {
        $this-&gt;api_key = $api_key;
        $this-&gt;file_temp_location = $file_temp_location;
        $this-&gt;file_name = $file_name;
        $this-&gt;upload();
    }
 
 
 
    private function upload() {
 
        $image_info = getimagesize($this-&gt;file_temp_location);
 
        if ($image_info !== false &amp;&amp; in_array($image_info['mime'], array(&quot;image/png&quot;, &quot;image/jpeg&quot;, &quot;image/pjpeg&quot;, &quot;image/gif&quot;))) {
            $fh = fopen($this-&gt;file_temp_location, &quot;rb&quot;);
            $file_contents = fread($fh, filesize($this-&gt;file_temp_location));
            fclose($fh);
            $data = array(&quot;image&quot; =&gt; base64_encode($file_contents));
            $options = array('http' =&gt; array(
                'method'  =&gt; 'POST',
                'header' =&gt; 'Authorization: Client-ID ' . $this-&gt;api_key,
                'content' =&gt; http_build_query($data)
            ));
            $context  = stream_context_create($options);
            $result = file_get_contents($this-&gt;api_url, false, $context);
            $result = json_decode($result);
            $url = $result-&gt;data-&gt;link;
            echo json_encode(array('url' =&gt; $url));
        } else {
            echo &quot;Could not upload image: invalid format.&quot;;
        }
 
    }
 
 
 
}
 
 
if ($_POST) {
    $imgur_api_key = 'YOUR_IMGUR_CLIENT_ID'; //replace with the &quot;client ID&quot; Imgur gives you
    $imgur = new TweetbotImgurEndpoint($imgur_api_key, $_FILES['media']['tmp_name'], $_FILES['media']['name']);
}
</pre>
<p>Just upload that to your web server, replace <code>YOUR_IMGUR_CLIENT_ID</code> with <a href="https://api.imgur.com/oauth2/addclient">a client ID obtained from here.</a> (You want to select the &#8220;anonymous usage without user authorization&#8221; option.)</p>
<p><strong>Edit, 2013/10/25:</strong> Imgur has since changed their API. This post has been updated to reflect the changes. If you&#8217;re looking for the original code, for version 2 of the API, it can be found in <a href="https://gist.github.com/redwallhp/7165014">this GitHub Gist.</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2012/10/20/adding-imgur-support-to-tweetbot-for-mac/feed/</wfw:commentRss>
		<slash:comments>1</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>Twitter Launches &#8220;New New Twitter&#8221; and Ruins iOS App</title>
		<link>https://www.webmaster-source.com/2011/12/09/twitter-launches-new-new-twitter-and-ruins-ios-app/</link>
		<comments>https://www.webmaster-source.com/2011/12/09/twitter-launches-new-new-twitter-and-ruins-ios-app/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 09:06:14 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Redesign]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4434</guid>
		<description><![CDATA[Starting Thursday, Twitter began rolling out their latest redesign, dubbed &#8220;New New Twitter&#8221; by users. The new design looks okay, albeit a bit heavy on the boxes, but some of the changes it brings aren&#8217;t so welcome. It seems to me as if Twitter is slowly strangling the brilliant simplicity that made it unique and [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Starting Thursday, Twitter began rolling out their latest redesign, dubbed &#8220;New New Twitter&#8221; by users. The new design looks okay, albeit a bit heavy on the boxes, but some of the changes it brings aren&#8217;t so welcome. It seems to me as if Twitter is slowly strangling the brilliant simplicity that made it unique and successful, and making the service more and more like Facebook.</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4435 imageborder" title="New New Twitter: Home Timeline" src="//www.webmaster-source.com/wp-content/uploads/newnewtwitter-home-redwall_hp.jpg" alt="" width="600" height="347" /></p>
<p>The first change that irks me is the new Connect screen, which replaces the Mentions tab. Instead of getting a listing of replies or tweets mentioning your username, you get something closer to a Facebook feed. The stream is cluttered with messages along the lines of &#8220;Mr. Follower and 6 others are now following you. Isn&#8217;t that great?&#8221; Oh, and anytime someone retweets one of your updates, it goes in there too. You can still get to the Mentions timeline, but it requires a second click. I imagine it&#8217;s even more &#8220;useful&#8221; if you have a half million followers.<span id="more-4434"></span></p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4436 imgborder" title="New New Twitter: 'Connect' Screen" src="//www.webmaster-source.com/wp-content/uploads/newnewtwitter-annoying-connect-screen.jpg" alt="" width="600" height="290" /></p>
<p>I&#8217;m still not sure where they buried the Direct Messages page. I know it must be around here somewhere&#8230;</p>
<p>Next on the list is <a href="http://techcrunch.com/2011/12/08/new-twitter-brand-pages/">&#8220;Brand Pages.&#8221;</a> Now the Twitter profiles for large brands get a few extra features that, while I&#8217;m sure they find useful, kind of detract from the Twitter experience and remind me of Myspace. (Remember them?)</p>
<p>Brand pages get to have a graphical banner on their profile, right above the timeline. They also get to make a featured tweet &#8220;sticky&#8221; and pin it to the top of their timeline. Oh, and did I mention any linked photos or videos in those sticky tweets get auto-expanded?</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4437 imgborder" title="New New Twitter: Brand Page" src="//www.webmaster-source.com/wp-content/uploads/newnewtwitter-brand-page.jpg" alt="" width="600" height="291" /></p>
<p>Now for the icing on the cake. Remember Loren Brichter&#8217;s excellent iOS app? Formerly known as Tweetie, it won an Apple design award before Twitter bought it and made it the official app. Well, Twitter has completely scrapped that codebase and replaced it with something that reminds me of Facebook&#8217;s kludgy app. It&#8217;s missing many of the great features of the old app, and feels very watered down in comparison. But it looks and acts more or less the same on Android, which is&#8230;good for Android users, I guess.</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4438 imgborder" title="New New Twitter: iOS App" src="//www.webmaster-source.com/wp-content/uploads/newnewtwitter-ios-app.jpg" alt="" width="560" height="420" /></p>
<p>Gruber <a href="http://daringfireball.net/2011/12/new_twitter">nailed it in his review.</a></p>
<blockquote><p>&#8230;today’s new Twitter, is something else. It’s an attempt at a best way to do Twitter that is as consistent as possible across multiple platforms, ranging from the iPhone to Android to the mobile and desktop web. I don’t want an iPhone app that’s constrained by the restrictions of a mobile web app. The whole reason I prefer native apps is that I like experiences that far exceed what can be done in a web app. This is a native app that looks and feels like it was designed and polished according to the norms of web apps, not other native iPhone apps.</p></blockquote>
<p>It looks to me like #NewNewTwitter is the new <a href="http://scripting.com/2011/03/06.html">#Dickbar</a>. Fortunately, there are still plenty of third-party apps, which have had an <a href="http://thenextweb.com/apps/2011/12/09/iphone-twitter-clients-like-tweetbot-saw-boost-in-sales-from-twitter-4-0-release-backlash/">increase</a> in sales since the update. (<a href="http://click.linksynergy.com/fs-bin/stat?id=1VLWDdrGBrI&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252F%252Fid428851691%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30">Tweetbot</a> and <a href="http://click.linksynergy.com/fs-bin/stat?id=1VLWDdrGBrI&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Ftwittelator-neue-twitter-client%252Fid469270564%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30">Twittelator Neue</a> are a couple of good ones.)</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/12/09/twitter-launches-new-new-twitter-and-ruins-ios-app/feed/</wfw:commentRss>
		<slash:comments>2</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>Twitter to Wrap All Links with t.co Starting in October</title>
		<link>https://www.webmaster-source.com/2011/09/23/twitter-to-wrap-all-links-with-t-co-starting-in-october/</link>
		<comments>https://www.webmaster-source.com/2011/09/23/twitter-to-wrap-all-links-with-t-co-starting-in-october/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 11:55:43 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[URL Shortening]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4316</guid>
		<description><![CDATA[According to the Twitter developer documentation, Twitter plans to start wrapping all links with their t.co shortener starting in October. Currently, only ones over a certain length are wrapped. So if you&#8217;re like me, and have a personal URL shortener that generated smaller links than t.co, you probably think this move is a little silly. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="https://dev.twitter.com/docs/tco-url-wrapper">According</a> to the Twitter developer documentation, Twitter plans to start wrapping all links with their t.co shortener starting in October. Currently, only ones over a certain length are wrapped.</p>
<p>So if you&#8217;re like me, and have a personal URL shortener that generated smaller links than t.co, you probably think this move is a little silly.</p>
<p>On the plus side, Twitter.com and the official Twitter clients (as well as any that use the right API methods) automatically expand all t.co links and display the URL they point to. So users should optimally never see the t.co URLs at all. If you continue to use your own shortener, it&#8217;s URLs will be re-wrapped, but users will still see your link.</p>
<p>Developers should check out the <a href="https://dev.twitter.com/docs/tco-url-wrapper">t.co URL Wrapper</a> documentation page, as well as the wrap_links parameter in the <a href="https://dev.twitter.com/docs/api/1/post/statuses/update">statuses/update</a> API method.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/09/23/twitter-to-wrap-all-links-with-t-co-starting-in-october/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bootstrap: Twitter&#8217;s CSS Framework</title>
		<link>https://www.webmaster-source.com/2011/09/05/bootstrap-twitters-css-framework/</link>
		<comments>https://www.webmaster-source.com/2011/09/05/bootstrap-twitters-css-framework/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 12:36:57 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4273</guid>
		<description><![CDATA[Twitter has a new CSS framework, named Bootstrap, that they launched recently, which includes things like grids, custom form styles, tooltips and popovers, etc.. Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more. It supports [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Twitter has a new CSS framework, named <a href="http://twitter.github.com/bootstrap/">Bootstrap</a>, that they launched recently, which includes things like grids, custom form styles, tooltips and popovers, etc..</p>
<blockquote><p>Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.</p></blockquote>
<p>It supports modern, standards-compliant browsers, but I imagine some of the niftier features would probably break down on older ones. That would be a big issue if you wanted to use Bootstrap for an ordinary website, but less so for &#8220;web apps,&#8221; where it&#8217;s more common to assume a user has a modern browser.</p>
<p>I haven&#8217;t tried Bootstrap yet, but you can give it a test run by hotlinking the 7kb minified CSS from their GitHub repository. Or download the LESS files from the repository if you want to customize it.</p>
<p><a href="https://dev.twitter.com/blog/bootstrap-twitter">Bootstrap from Twitter</a> [Twitter Developer Blog]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/09/05/bootstrap-twitters-css-framework/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Adding and Tracking Social Buttons</title>
		<link>https://www.webmaster-source.com/2011/07/15/adding-and-tracking-social-buttons/</link>
		<comments>https://www.webmaster-source.com/2011/07/15/adding-and-tracking-social-buttons/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 11:24:36 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[(x)html]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4140</guid>
		<description><![CDATA[It seems like every website has social media buttons on them now. The ones leading the pack of late seem to be Twitter, Google +1 and the Facebook Like widget. This introduces one problem: loading times. Your pages are calling JavaScript files hosted on remote servers, bogging them down a bit. Joost de Valk has [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>It seems like every website has social media buttons on them now. The ones leading the pack of late seem to be Twitter, Google +1 and the Facebook Like widget. This introduces one problem: loading times. Your pages are calling JavaScript files hosted on remote servers, bogging them down a bit.</p>
<p>Joost de Valk has put together <a href="http://yoast.com/social-buttons/">a good tutorial on how to fix that issue</a>. It features code snippets that will load the widget JavaScript asynchronously, keeping the buttons from holding up the page loading. Also, it even adds Google Analytics and Clicky tracking so you can tell if people are actually using your buttons.</p>
<blockquote><p>When Google released +1, I quickly identified <a href="http://yoast.com/plus-one-google-analytics/">how to track interaction with that button</a>.  The obvious &#8220;follow up&#8221; was questions from people on how to track  interaction with other buttons. Not for each of these social buttons  tracking of interaction is actually possible. It depends on how the  button was designed whether this will work or not. I got it working for  Twitter and Facebook, so I&#8217;ll share the code for tracking interaction  with their respective social buttons below.</p></blockquote>
<p><a href="http://yoast.com/social-buttons/">Social Buttons: Adding them to your site &amp; Tracking them</a> [Yoast]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/07/15/adding-and-tracking-social-buttons/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:44:11 by W3 Total Cache
-->