Demo – How to Pull Your Google Buzz with jQuery
[inline]
[script type="text/javascript"]
// < ![CDATA[
$(document).ready(function(){
// passing your username, number of buzzes, div
getGoogleBuzz('mikedotmore', 5, $('#my-buzz'));
});
function getGoogleBuzz(username,n, div){
// params for Google Feed API proxy : Buzz Feed URL, Number of Entries
var data = {q:'http://buzz.googleapis.com/feeds/'+username+'/public/posted'
,num:n
,output:'json'
,v:'1.0'};
// call Google Feed API
$.ajax({
url:'http://ajax.googleapis.com/ajax/services/feed/load'
,data:data
,dataType:'jsonp'
,success:function(json){
// json from Google Feed API was returned successfully..
// error with Google Buzz feed ?
if(json.responseStatus!=200) {
div.html('‘+ json.responseDetails +”);
return;
};
// Buzz entries array
var entries= json.responseData.feed.entries;
var length= entries.length;
// no entries!
if(length==0) return;
// start output by appendding a hidden unordered list
var ul = $(‘
‘).appendTo(div.html(”));
// loop buzz entries ‘); // now show the unordered list
for(var i=0; i
var pDate = new Date(entries[i].publishedDate);
// using entry snippet version
var snippet = entries[i].contentSnippet;
// convert links that start with http to hyperlinks using regular expression
snippet = snippet.replace(/b(https?://S+)/gi,' $1′);
// append buzz to UL
ul.append(‘
+’‘+ snippet +’‘
+’‘
+’
};
ul.show(‘slow’);
}
});
}
// ]]>
[/script]
[/inline]