Search code examples
jqueryjsontwittertimeline

Display Twitter feed with a JSON file


I have an extracted twitter feed (.json file) with some tweets in it and I just want to display it but for some reason my code doesn't work. Can anyone help me?

JSFiddle: http://jsfiddle.net/tsokekLw/

Code:

    <html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $.ajax({
    url: 'https://dl.dropboxusercontent.com/u/9239655/kevynlebouille.json',
    dataType: 'jsonp',
    success: function(dataWeGotViaJsonp){
      var text = '';
      var len = dataWeGotViaJsonp.length;
      for(var i=0;i<len;i++){
        twitterEntry = dataWeGotViaJsonp[i];
        text += '<p><img src = "' + twitterEntry.user.profile_image_url_https +'"/>' + twitterEntry['text'] + '</p>'
      }
      $('#twitterFeed').html(text);
    }
  });
})
</script>
</head>
<body>
  <div id='twitterFeed'></div>
</body>
</html>

Solution

  • You have to change this

    dataType: 'jsonp',
    

    to this

    dataType: 'json',
    

    JSFIDDLE