技巧:博客圈的json输出 in feedsky
json: http://network.feedsky.com/test_fn/json?d=0&c=15&p=2&e=gbk&v=obj
feedsky发布了新的博客圈系统,并提供了json输出的支持
上面的代码就是我建的一个博客圈的json输出地址
d代表是否输出描述
c代表输出条数
p代表输出的页面(json版的支持分页显示!)
e代表输出的编码(建议使用utf-8或者gbk!)
v代表输出的变量名
比如这个地址的内容 (http://network.feedsky.com/test_fn/json?d=0&c=1&p=1&e=utf-8&v=obj)
稍微整理了下 :)

obj={
  title:'测试博客圈',
  description:'测试博客圈\ntesting...',
  is_page_end:'',
  item_count:'',
  items:[
    {title:'笔记:构建分页导航',
     pubDate:'Thu, 07 Jun 2007 16:32:13 +0800',
     link:'http://item.feedsky.com/~feedsky/fallseir/~1247382/7460200/1223971/1/item.html'
    }],
  encoding:'utf-8'
};
obj->
   title // 圈子标题
   description // 圈子描述
   is_page_end // 是否达到页尾
   item_count // 总条数,可能为空,代表还没有得到
   items-> // 文章集合
    [0]-> // 第一篇
      title // 文章标题
      pubDate // 发布时间
      description // 内容
      link // 链接
   encoding // 输出编码

一段用来输出的代码
function renderfeed(feed,box_id){
	if(typeof(box_id)=="string"){
		box=document.getElementById(box_id);
	}else{
		box=box_id;
	}
	html="";
	for(var i=0;i<2;i++){
		var item=feed.items[i];
		html+='<p style="margin-bottom:8px;"><a href="'+item.link+'" class="t">'+item.title+"</a><br />";
		if(feed.items.length==1){
			if(item.description.length>150){
				item.description=item.description.substring(0,150)+"... ...";
			}
		}else{
			if(item.description.length>60){
				item.description=item.description.substring(0,60)+"... ...";
			}
		}
		html+=item.description;
		html+='<span class="orange_12"></span> <a href="'+item.link+'"></a></p><br/>';
	}
	//html+="<p> </p>";
	box.innerHTML=html;
	return 1;
}

看完了要说点啥么?

You must be logged in to post a comment.