/ Published in: jQuery
Updated code (December, 2012) to get a tweet from a user's twitter timeline using JSON and jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE html> <html> <head> <title>JSON Example</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script type="text/javascript"> function getTweet(){ $.getJSON("https://api.twitter.com/1/statuses/user_timeline/uniofgreenwich.json?count=1&callback=?", function(data){ $("#twitter").html("<a href='http://twitter.com/#!/uniofgreenwich/status/"+data[0].id_str+"'>" + data[0].text + "</a>"); }); } $(document).ready(function(){ getTweet(); }); </script> </head> <body> <p id="twitter"></p> </body> </html>