Posted By

eddequincey on 02/17/11


Tagged

jquery json twitter


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Some0ne
sethetter
jondiscipulo
Balamir


Get a tweet from user timeline using JSON and jQuery


 / Published in: jQuery
 

Updated code (December, 2012) to get a tweet from a user's twitter timeline using JSON and jQuery

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>JSON Example</title>
  5. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
  6. <script type="text/javascript">
  7. function getTweet(){
  8. $.getJSON("https://api.twitter.com/1/statuses/user_timeline/uniofgreenwich.json?count=1&callback=?",
  9. function(data){
  10. $("#twitter").html("<a href='http://twitter.com/#!/uniofgreenwich/status/"+data[0].id_str+"'>" + data[0].text + "</a>");
  11. });
  12. }
  13.  
  14. $(document).ready(function(){
  15. getTweet();
  16. });
  17. </script>
  18. </head>
  19. <body>
  20. <p id="twitter"></p>
  21. </body>
  22. </html>

Report this snippet  

You need to login to post a comment.