Twitter Hack – Detecting Recent Visitors

Twitter has been in the news lately for all the wrong reasons. Here is another “feature” that could either compromise a lot of people’s privacy or could be great add-on to any blog.

Since most Twitter users are logged in at all times, all we need to do is use this javascript API call to get the details of the current visitor.

<script src="http://twitter.com/statuses/user_timeline.json?count=1&hasTwitter&suppress_response_codes" type="text/javascript"></script>

The URL returns data in the JSON format, which is then handled by the callback function, which in our case is hasTwitter.

function hasTwitter (data) {
  alert (data[0].user.name);
}

This code sample simply prompts the Twitter username of the current user, but you could also display the avatar, the last update or the follower count.

Find this article at: http://www.labnol.org/internet/favorites/twitter-hack-detecting-recent-visitors/6396/

Tags: , , Tumblelog



Google Custom Search