Skip to content

Instantly share code, notes, and snippets.

@liquorice
Created June 23, 2011 05:49
Show Gist options
  • Save liquorice/1041979 to your computer and use it in GitHub Desktop.
Save liquorice/1041979 to your computer and use it in GitHub Desktop.
bare bones method for grabbing and updating a users latest tweet (with no error handling whatsoever)
$.ajax({
url: 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=someonesplendid',
dataType: 'jsonp',
success: function(data) {
var tweet = data[0].text;
tweet = tweet.replace(/(http\:\/\/[A-Za-z0-9\.\/_]+)/g, '<a href="$1">$1</a>');
tweet = tweet.replace(/@([a-zA-Z0-9_]+)/g, '<a href="http://twitter.com/$1">@$1</a>');
$('#tweet').html(tweet);
}
});
@makenosound
Copy link

Works great, but needs the data parameter in the callback.

@liquorice
Copy link
Author

so it does! i missed that out when i moved the callback function inline. fixed, thanks max.

@makenosound
Copy link

FYI: Am using it on http://swipeconference.com.au/ with a little addition for pulling out the time and formatting relative to now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment