I am using the following code to grab the twitter data from a specific user and outputting it to a div, However it is not working. Nothing is outputting, I am really not sure if I am doing this right, I took this forked this snippet from someone else. I am not sure if I need to authenticate with twitter and how to do so?
http://jsfiddle.net/elijahmanor/Nstnx/22/
Js
$(function(){
var twitterUsername = 'anderskitson'
var url = "http://twitter.com/status/user_timeline/" +
twitterUsername +
".json?count=5&callback=?";
$.getJSON( url, function( data ) {
var twitterList = $( "<ul />" );
$.each( data, function( index, item ) {
$( "<li />", { "text" : item.text } )
.appendTo( twitterList );
});
$( "#output" ).fadeOut( "fast", function(){
$( this ).empty()
.append( twitterList )
.fadeIn( "slow" );
});
});
You are using an old form of the URL. That form has been deprecated. You also need to add
callback=somethingto the URL so that it will use JSONP and get past the cross origin issue. Also, update your jQuery to the latest version. The fiddle was using an old version.Try this code: