Nel tutorial di oggi imparerete come effettuare un grab dei Tweets utilizzando Javascript.

 
function getTweets(handle, tweetHash) {
 
// Create a ul for the Twitter statuses:
var twitter_nod = jQuery(

     
    ).insertAfter("#tweets");
    var maxTweets = 3;
    // Get & parse json object:
    var JSONCallback = function(data) {
    var html = ;
    var count = 0;
     
    $.each(data, function(i,item) {
     
    var content_str = item.text;
    var content_created = item.created_at;
     
    if (item.text.toLowerCase().indexOf(tweetHash) === -1 || count > maxTweets) {
    return true; /*continue*/
    }
     
    content_str = content_str.replace(/http:\/\/\S+/g, $&);
    content_str = content_str.replace(/(@)(\w+)/g, ‘ @$2);
    content_str = content_str.replace(/(#)(\w+)/g, ‘ #$2);
    //evenOdd_str = i % 2 == 0 ? ‘odd’ : ‘even’;
    //$("#twitter-feed").append(‘

  • ‘+content_str +’
  •  
    ‘);
     
    html += ‘

     
    ‘ + content_str + ‘‘ + calcTime(content_created) + ‘
     
    ‘;
    count++;
    });
     
    var $tweets = $("#tweets");
     
    if (html == ‘
    ‘) {
    html = ‘

     
    There are no tweets.
     
    ‘;
    }
     
    $tweets.append(html);
     
    };
     
    $.getJSON("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=" + handle + "&count=200&callback=?",JSONCallback);
    }

    fonte: www.sastgroup.com ? Vai al post originale