星光大道聯播:將FunP推推王的超級星光大道文章加入自己部落格

最近研究 Yahoo Pipes推推王,自己動手作了星光大道文章聯播。
先在推推王查詢關鍵字 "超級星光大道",取得查詢結果(Atom)。
然後在Yahoo Pipes中利用推推王的查詢結果,依照日期作排序,最新的日期排在最前面。


如果你的部落格平台可以支援html/javascript,那就可以使用這個星光大道文章聯播。這些文章都是來自推推王所被張貼的文章,會動態顯示目前最新星光文章。

請把複製以下程式碼,再貼到你的部落格平台所支援的地方。

程式碼所標示的紅色字體部分,可以自己修改。

可以修改為顯示的資料筆數(這裡設定為顯示15筆資料)
var postRecord=15;

調整要顯示文章內容的字數,如果不想要顯示文章內容,那就設定為(0,0)就可以了。
var description=post.description.substr(0,40);


<div id="rssSsupersatr">
<h2>Loading...</h2>
</div>

<script>
function rssSsupersatr(json) {
var html= '<ul>';
var postshow=15;
var items=json.value.items;
for (var i=0, post; post = items[i]; i++) {
if(i>=postshow) break;

var title=post.title;
var link=post.link;
var description=post.description.substr(0,40);


html+= '<li><a href="'+link+'">'+ title +'</a><br/>'+description;
}
html+= '</ul>';
document.getElementById("rssSsupersatr").innerHTML = html;
}
</script>


<script src="http://pipes.yahoo.com/pipes/pipe.run?_id=omeZKdYp3BGakAysCB2yXQ&_render=json&_callback=rssSsupersatr" type="text/javascript"></script>



以下是 呈現的結果:



Loading...





留言