I was working on a component for a client that uses search.twitter.com to find all relevant tweets based on a query string recently and I noticed there’s a lot of other samples out there that use some hefty XML parsing code to sift the data rather than make life easy with e4x. The Twitter search API uses XML namespaces in its results, and it seemed that many other posts out on the intertoobs (can I coin this term?) were implying that it caused problems within AS3. Not true. Since I didn’t find a lot on the Twitter search topic specifically, a new blog post was born. The following is a quick and easy sample of how to use e4x in your XML results by using the given XML namespaces.
For this client’s component, I didn’t need to authenticate users, but rather, search for all public streams via a query string. If you take a look at the Twitter search API docs you can see the process pretty straightforward, it’s just using URL query strings to retrieve data . Generally, you can search for tweets:
- containing a word
- from a user
- to a user
- referencing a user
- containing a hashtag
- or combining any of these options together