新闻接入说明(AMS数据源)
- 对接接口人提供相对应新闻分类的数据源地址,只需要替换相对应的数据url就可以(地址如://cf.qq.com/webplat/info/news_version3/125/26813/26814/m128/index.js)
- 想要展示哪些分类,找到url上对应id参数的值,展示内容的ID(newslist),比如这样(getNewsList(url);),修改css即可实现想要效果
<div class="news-box">
<ul class="newslist" id="newslist"></ul>
</div>
<script src="//ossweb-img.qq.com/images/cf/script/jquery-1.9.1.min.js"></script>
getNewsList('//cf.qq.com/webplat/info/news_version3/125/26813/26814/m128/index.js');
function getNewsList(url){
$.getScript(url,function(){
var newslistPanel = '';
for(x in newsIndexData){
if(x<8){
if(x < 1){
newslistPanel += '<li class="fir"><a href="'+newsIndexData[x]['infoPath']+'" title="'+substring( decodeURIComponent(newsIndexData[x]['sTitle']) )+'" target="_blank"><i>'+substring( decodeURIComponent(newsIndexData[x]['sTitle']) )+'</i></a><span class="date">'+substring( decodeURIComponent(newsIndexData[x]['dtReleaseTime']) )+'</span></a></li>';
}else{
newslistPanel += '<li><a href="'+newsIndexData[x]['infoPath']+'" title="'+substring( decodeURIComponent(newsIndexData[x]['sTitle']) )+'" target="_blank">'+substring( decodeURIComponent(newsIndexData[x]['sTitle']) )+'</a><span class="date">'+substring( decodeURIComponent(newsIndexData[x]['dtReleaseTime']) )+'</span></a></li>';
}
}
}
$("#newslist").html(newslistPanel);
})
}
function substring(str){
if(str.length > 24){
return str.substring(0,24)+'...';
}
return str;
}
案例地址