HOW TO show expanded form of shortened URL within a tweet using Twitter API


The Twitter micro-blogging service converts URLs within a tweet to a shortened form using its t.co domain to conserve the number of characters so that users can pack more into a 140-character limited tweet.

Some evil guys misuse this service to cloak hyperlinks to shady websites. An unsuspecting reader may fall into the trap if the tweet is crafted to make the user click the link.

While security is one reason why a developer may want to show the expanded form of the URL while displaying a customized view of a Twitter stream, there are other benefits of using the expanded URL that the Twitter API provides. If the expanded URL points to an image or video, the URL can be parsed to show it directly in the customized view.

Here's a code sample to show expanded URLs alongwith tweets. It utilizes a script from the CodeBrunch site that displays a collection of Tweets with "infinite scrolling" -

Comments