Created
March 1, 2012 07:46
-
-
Save atomize/1948101 to your computer and use it in GitHub Desktop.
jQuery search Twitter - get results in JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Search Twitter</title> | |
</head> | |
<body> | |
<input type="text" id="query" /><button>search</button><br /> | |
<div id="results"> | |
</div> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
var url='http://search.twitter.com/search.json?callback=?&q='; | |
var query; | |
$('button').click(function(){ | |
query=$("#query").val(); | |
$.getJSON(url+query,function(json){ | |
$.each(json.results,function(i,tweet){ | |
$("#results").append('<p><img src="'+tweet.profile_image_url+'" width="48" height="48" />'+tweet.text+'</p>'); | |
}); | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment