Web Design Blog

This is where we store some of our Web Development thoughts, tips and tricks, just because we like to share.

How To Display Latest Tweet On Website

Here’s a really quick and simple way to display your latest Tweet on your website like the example below (the graphics obviously won’t appear, just the Tweet):

Latest Tweet

1
2
3
4
5
6
7
8
9
10
11
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function ()
{
 $.getJSON("http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?", function(data) {
  $(".show_tweet").html(data[0].text);
 });
});
</script>
 
<div class="show_tweet"></div>

Simply replace USERNAME with your unique Twitter username. The show_tweet class is where the Tweet will display.

The “follow us” link won’t appear by default, I hard-coded that into the show_tweet div :)

It’s as easy as that.

30 Nov 2011 / 3 Comments / jQuery Scripts & Helpful Snippets / by Maruf

3 Comments

  1. Roberto Torres
    04/12/2011
    1

    Thanks for such an excellent code!!

    I have a question for you, what is needed to put a specific font into the latest tweet? Let’s say Verdana.

  2. Jacob Rantor
    18/02/2012
    2

    Whereas this works its flawed.

    It works fine if you only get a few visits an hour. But when you get good traffic the requests fail and you have no fallback so you are left with an empty box.

    How would you fix that?

  3. Mishow
    12/04/2012
    3

    It didn’t work for me, nothing gets displayed.

Leave a Reply

© 2012 BrightCherry :)