GirlieMac!

Archive for the ‘Twitter’

Find Your Tweeting Neighbor on iPhone with GeoLocation

June 21, 2009 By: admin Category: Dev, Firefox, Sandbox, Twitter, WebKit, iPhone No Comments →

screenshot

iPhone OS 3.0 is now available, and developers can take advantage of the newly introduced geolocation feature in Safari browser.

To try it out quickly, I used Twitter Search API again to create a tiny test app called, NeighborTweet, which enable you to find out who are tweeting in your neighborhood. Basically, what it does is that obtain your location, and pass the latitude and longitude data to Twitter search and display the result tweets.

Try it out on your iPhone with:
Short URL http://bit.ly/K0ZaE
or
This QR Code with scanning app like BeeTagg.

If you are interested in learning more on Twitter search API and geocode, please read Twitter Wiki.

OK, now here’s the code.
To find out your location with Geolocation class is simple – you just call getCurrentPosition() method. This initiates an asynchronous request to detect the user’s position.


navigator.geolocation.getCurrentPosition(someFunction)

Get latitude and longitude, by using coords instance:


latitude = position.coords.latitude;
longitude = position.coords.longitude;

Here’s an actual code I used to create the sample app:


if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    callback(position.coords.latitude, position.coords.longitude);
  });
} else {
  alert("Geolocation services are not supported by your browser.");
} 

function callback(lat,lon){
  // twitter search json-p callback
  var geocode = "&geocode=" + lat + "%2C" + lon + "%2C1mi";
  var fullUrl = url + geocode;
  ...
}
var url = "http://search.twitter.com/search.json?callback=getTweets";

function getTweets (json) {
  // display json data
  ...
}

References

Geolocation References:

More References:

TweetTrendDunno – Played with APIs

June 16, 2009 By: admin Category: App, GirlieMac! News, Sandbox, Twitter No Comments →

TweetTrendDunno screenshot
I had a plenty of time to stay home and play with code right now so I mashed Twitter trend API, mixed with some BOSS news and image search stuff I used before, also Microsoft’s new Bing search results to create some silly and handy web app called TweetTrendDunno.

Basically, this grabs Twitter “trending topic” terms, and as a user click on each term you want to know about, it displays news articles, images, and Bing results (usually summary from Wikipedia helps you to figure out what the term means in general).

If you are Twitter user and ever wonder what people are talking about, give TweetTrendDunno a try!