A blog for technology, SEO tips, website development and open source programming.

Get Last Tweet via JQuery

0 959

Twitter, has a rich API and it allows you to deal with many things. In this example we are going to learn how to use jQuery to get the latest tweet of a user.

Twitter API

Get the last tweet of a user, simply by changing  “username” in the following url:

http://search.twitter.com/search.json?q=from:username&rpp=1

For example, in order to get my latest tweet from my twitter:

http://search.twitter.com/search.json?q=from:panay_georgiou&rpp=1

 

1. jQuery Ajax

We use Jquery .ajax() function to get the last tweet of the user and display it.

$(‘#last-tweet’).click(function(){

$(“#tweet_result”).text(“Loading……”);

var username = $(‘#username’).val();

$.ajax({

type: “GET”,

dataType: “json”,

url: “http://search.twitter.com/search.json?q=from:”+username+”&rpp=1&callback=?”,

success: function(data){

$(“#tweet_result”).text(data.results[0].text);

}

});

});

2.Download the Full HTML Example

Download example

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More