teaching machines

Homework 3 – News of the world

November 6, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

This time I made a simpler application largely based using he twitter API. I was slightly disappointed with how much I implemented, but I would probably like to expand on this application in the future for personal use.

It’s a simple trend following application. You can see the either Worldwide Trends or United States trends (I’d like to add more depth to where you can search, more on why I didn’t do that later). From there, you can pick a trend, and either see the three most popular tweets or search the topic on google.

I used two twitter API calls. The first one was to receive the tweets, either from the World or the US, based on a WOEID number. WOEIDs are distributed by the Yahoo geolocation API. Instead of signing up, I just searched around and added the US number as an option (while “World” is just 1).  I’d like to in the future use the yahoo API and add functionality so you can search at any level of locality for your current location (ie: search trends for your zip code, city, county, state, country or the whole world). Also, the trend search has an added parameter of what to exclude stuff. You can set it to exclude all hashtags. I set it to do just that, which is to help my google searches, and to attempt to keep it more based on topics, rather than just ideas. I’d also like to be able to exclude trends in all caps, but it didn’t seem feasible. Note that no matter what you exclude, this API call always returns 10 trends.

The second API call was to return the tweets. So I searched off the trend query parameter from the trends  received. There’s a parameter for the kind of search, “recent”, “popular” and “mixed”. I wanted to get the most popular tweets, but if it’s set to “popular” it only gets the single most popular tweet. Mixed returns the 3 most popular tweets and then a bunch more recent tweets. So I used mixed, and only took the first three results. If you click on the tweet, it will toast who tweeted it, and how many times it has been retweeted.

Additional functionality I would have liked to add to the tweet activity (and I realized why I couldn’t before) was if the tweet had a link, you could long click it to go to the page it linked to. The tweet has a entities list parameter, which then contains a links list parameter, according to the twitter API. Only JSON kept failed on the breaking down of the results. A way I broke apart the bundles to see if they had what I needed was to run an iterator on the JSONObject.keys() and logged each of the keys whenever it broke, it was a useful way to debug JSONObjects.

Then I realized that the list parameters might not even be there if there’s no links in the tweets, and none of the tweets I was looking at had links. So, I’d need to manage the breaking down of the JSONObject to take a link from the JSONObject only if the link is present. And to make a user’s life better, I could make it so that before being taken to a url, I could use a link expander API (I saw plenty when looking around for APIs) to show the user where they’re actually going before taking them there.