接口名称:channelList
参数说明:
名称 | 类型 | 是否必选 | 说明 |
offset |
int | 是 | 当前游标偏移量 |
count | int | 否 | 请求总数,默认为10 |
{ "client": { "height": 1280, "width": 720 }, "data": { "offset": 1, "count": 50 }, "token": "" }
返回实例:
{ "service": "channels", "state": { "tips": null, "code": 200, "msg": "OK" }, "data": { "content": [ { "id": 98, "cid": "T1370583240249", "cname": "原创", "subnum": "9.7万", "extra": null }, { "id": 99, "cid": "T1348649145984", "cname": "NBA", "subnum": "3.1万", "extra": null }, { "id": 100, "cid": "T1348647909107", "cname": "头条", "subnum": "3.2万", "extra": null }, { "id": 101, "cid": "T1422935072191", "cname": "画报", "subnum": "2.4万", "extra": null }, { "id": 102, "cid": "T1348648037603", "cname": "社会", "subnum": "100", "extra": null }, { "id": 103, "cid": "T1368497029546", "cname": "历史", "subnum": "29.2万", "extra": null }, { "id": 104, "cid": "T1348648141035", "cname": "军事", "subnum": "11.1万", "extra": null }, { "id": 105, "cid": "T1444289532601", "cname": "哒哒", "subnum": "2152", "extra": null }, { "id": 106, "cid": "T1348648517839", "cname": "娱乐", "subnum": "22.3万", "extra": null }, { "id": 107, "cid": "T1348648650048", "cname": "影视", "subnum": "204.6万", "extra": null }, { "id": 108, "cid": "T1348648756099", "cname": "财经", "subnum": "22.1万", "extra": null }, { "id": 109, "cid": "T1356600029035", "cname": "彩票", "subnum": "3.1万", "extra": null }, { "id": 110, "cid": "T1348649079062", "cname": "体育", "subnum": "19.1万", "extra": null }, { "id": 111, "cid": "T1348649503389", "cname": "中国足球", "subnum": "1.8万", "extra": null }, { "id": 112, "cid": "T1348649176279", "cname": "国际足球", "subnum": "2.5万", "extra": null }, { "id": 113, "cid": "T1348649475931", "cname": "CBA", "subnum": "9837", "extra": null }, { "id": 114, "cid": "T1411113472760", "cname": "跑步", "subnum": "5648", "extra": null }, { "id": 115, "cid": "T1348649580692", "cname": "科技", "subnum": "27.5万", "extra": null }, { "id": 116, "cid": "T1348649654285", "cname": "手机", "subnum": "13万", "extra": null }, { "id": 117, "cid": "T1348649776727", "cname": "数码", "subnum": "10.4万", "extra": null }, { "id": 118, "cid": "T1351233117091", "cname": "移动互联", "subnum": "7.1万", "extra": null }, { "id": 119, "cid": "T1350383429665", "cname": "轻松一刻", "subnum": "604.3万", "extra": null }, { "id": 120, "cid": "T1421997195219", "cname": "云课堂", "subnum": "6080", "extra": null }, { "id": 121, "cid": "T1348654060988", "cname": "汽车", "subnum": "25.8万", "extra": null }, { "id": 122, "cid": "T1348654085632", "cname": "房产", "subnum": "23.5万", "extra": null }, { "id": 123, "cid": "T1348654105308", "cname": "家居", "subnum": "3.7万", "extra": null }, { "id": 124, "cid": "T1348654151579", "cname": "游戏", "subnum": "6.1万", "extra": null }, { "id": 125, "cid": "T1348654204705", "cname": "旅游", "subnum": "4.3万", "extra": null }, { "id": 126, "cid": "T1414389941036", "cname": "健康", "subnum": "1.5万", "extra": null }, { "id": 127, "cid": "T1401272877187", "cname": "读书", "subnum": "3.9万", "extra": null }, { "id": 128, "cid": "T1385429690972", "cname": "酒香", "subnum": "1.4万", "extra": null }, { "id": 129, "cid": "T1348654225495", "cname": "教育", "subnum": "3.1万", "extra": null }, { "id": 130, "cid": "T1397116135282", "cname": "亲子", "subnum": "2.5万", "extra": null }, { "id": 131, "cid": "T1402031665628", "cname": "葡萄酒", "subnum": "9772", "extra": null }, { "id": 132, "cid": "T1432711055315", "cname": "你照吗", "subnum": "1402", "extra": null }, { "id": 133, "cid": "T1397016069906", "cname": "暴雪游戏", "subnum": "2.3万", "extra": null }, { "id": 134, "cid": "T1444270454635", "cname": "漫画", "subnum": "2160", "extra": null }, { "id": 135, "cid": "T1348650593803", "cname": "时尚", "subnum": "24.9万", "extra": null }, { "id": 136, "cid": "T1348650839000", "cname": "情感", "subnum": "6.3万", "extra": null }, { "id": 137, "cid": "T1414142214384", "cname": "政务", "subnum": "2.6万", "extra": null }, { "id": 138, "cid": "T1441074311424", "cname": "艺术", "subnum": "2730", "extra": null }, { "id": 139, "cid": "T1420771091297", "cname": "值得买", "subnum": "4963", "extra": null }, { "id": 140, "cid": "T1419315959525", "cname": "跟贴", "subnum": "4.2万", "extra": null }, { "id": 141, "cid": "T1419316284722", "cname": "段子", "subnum": "6.9万", "extra": null }, { "id": 142, "cid": "T1419316384474", "cname": "图片", "subnum": "4.4万", "extra": null }, { "id": 143, "cid": "T1419316531256", "cname": "本地", "subnum": "8.8万", "extra": null }, { "id": 144, "cid": "T1419386592923", "cname": "论坛", "subnum": "5020", "extra": null }, { "id": 145, "cid": "T1427878984398", "cname": "热点", "subnum": "4.2万", "extra": null }, { "id": 146, "cid": "T1433137697241", "cname": "直播", "subnum": "3.8万", "extra": null } ], "nextOffset": -2, "type": 0 } }
接口名称:newsList
参数说明:
名称 | 类型 | 是否必选 | 说明 |
type | String | 是 | 频道ID |
offset |
int | 是 | 当前游标偏移量 |
count | int | 否 | 请求总数,默认为10 |
请求实例:
{ "client": { "height": 1280, "width": 720 }, "data": { "type": "T1370583240249", "offset": 1, "count": 10 }, "token": "" }
返回实例:
{ "service": "news", "state": { "tips": null, "code": 200, "msg": "OK" }, "data": { "content": [ { "id": 1262, "title": "俄土交锋将引发第三次世界大战?", "source": null, "cp": "热观察", "time": 1448396190000, "cid": "T1370583240249", "snapDetail": "别担心了,经济捆绑、大国制约,“硬汉”秀完就散了吧。", "icon": "http://img3.cache.netease.com/3g/2015/11/25/201511250431556b46b.jpg", "url": "http://3g.163.com/ntes/15/1125/04/B986K9500004662N.html", "extra": null }, { "id": 1263, "title": "12个关于“黑户”触目惊心的事实", "source": null, "cp": "热观察", "time": 1448374163000, "cid": "T1370583240249", "snapDetail": "100个中国人里有一个是黑户;黑户数量不止1300万。", "icon": "http://img5.cache.netease.com/3g/2015/11/24/20151124221128b154a.jpg", "url": "http://3g.163.com/ntes/15/1124/22/B97HK3680004662N.html", "extra": null }, { "id": 1264, "title": "两个中国弃婴的美国奇幻之旅", "source": null, "cp": "大国小民", "time": 1448367191000, "cid": "T1370583240249", "snapDetail": "美女子三年时间先后收养两弃婴,意外发现竟是亲生姐妹!", "icon": "http://img6.cache.netease.com/3g/2015/11/24/20151124203407ebdfe.jpg", "url": "http://3g.163.com/ntes/15/1124/20/B97AV9OG000465CI.html", "extra": null }, { "id": 1265, "title": "二孩放开,落户还要先上环?", "source": null, "cp": "热观察", "time": 1448278736000, "cid": "T1370583240249", "snapDetail": "上亿妇女被强制上环;\"先上环再落户\"没有法律依据。", "icon": "http://img6.cache.netease.com/3g/2015/11/23/201511231957029702e.jpg", "url": "http://3g.163.com/ntes/15/1123/19/B94MJSQS0004662N.html", "extra": null }, { "id": 1266, "title": "评:救急就不能\"特事特办\"?", "source": null, "cp": "网易新媒体", "time": 1448346764000, "cid": "T1370583240249", "snapDetail": "这到底是制度僵化,还是生命意识的匮乏? ", "icon": "http://img1.cache.netease.com/3g/2015/11/24/20151124143455a07a3.jpg", "url": "http://3g.163.com/ntes/15/1124/14/B96NFTHP00963VRO.html", "extra": null }, { "id": 1267, "title": "“亚洲最大”国有马场的凋敝", "source": null, "cp": "网易", "time": 1448357089000, "cid": "T1370583240249", "snapDetail": "军马场一万多职工如今陷于贫困,昔日辉煌一去不返。", "icon": "http://img4.cache.netease.com/3g/2015/11/24/20151124174717d42ef.jpg", "url": "http://3g.163.com/news/15/1124/17/B971B0MT000153N3.html", "extra": null }, { "id": 1268, "title": "李昆学曾为成都市长热门人选", "source": null, "cp": "路标", "time": 1448334139000, "cid": "T1370583240249", "snapDetail": "曾主抓天网工程,系李春城执政班底内第八名被查者。", "icon": "http://img1.cache.netease.com/3g/2015/11/24/20151124111228c7885.jpg", "url": "http://3g.163.com/ntes/15/1124/11/B96BEKPN0004662L.html", "extra": null }, { "id": 1269, "title": "图片故事:手机镜头下的地铁众生相", "source": null, "cp": null, "time": 1448272356000, "cid": "T1370583240249", "snapDetail": "在这行色匆匆的人群里,还曾记得与你擦身过的身影吗?", "icon": "http://img2.cache.netease.com/3g/2015/11/23/20151123175932b7a78.jpg", "url": null, "extra": null }, { "id": 1270, "title": "朝鲜重启经济特区,能成吗?", "source": null, "cp": "热观察", "time": 1448204008000, "cid": "T1370583240249", "snapDetail": "几次特区试验都失败,这次能带领朝鲜改革开放吗?", "icon": "http://img5.cache.netease.com/3g/2015/11/22/2015112223061925e35.jpg", "url": "http://3g.163.com/ntes/15/1122/22/B92FBBB80004662N.html", "extra": null }, { "id": 1271, "title": "招骂的放生:放生老鼠和毒蛇", "source": null, "cp": "槽值", "time": 1448271902000, "cid": "T1370583240249", "snapDetail": "放生自古即有血色利益链,也可能破坏生态环境。", "icon": "http://img2.cache.netease.com/3g/2015/11/23/201511231757570334c.png", "url": "http://3g.163.com/news/15/1123/17/B94G3ATC0001544E.html", "extra": null } ], "nextOffset": 11, "type": 0 } }
频道:ChannelsController
1.channelList()
负责获取频道列表。
1.newsList
负责获取新闻列表。
1.代码位置
https://github.com/pgq10240817/PlayNews
anndroid:https://github.com/pgq10240817/PlayNews/tree/master/client/AndroidNews
eclipse工程。
HOST切换在HttpURLTag : HOST类里面。
抽取了一些基类,封装了下vollery。
道友若是想替换package,可以运行下面这个pathon文件替换package
https://github.com/pgq10240817/PlayNews/tree/master/client/AndroidNews/scripts/package.py
server:
https://github.com/pgq10240817/PlayNews/tree/master/server/myNews
抽取了model查询类,主要是想缓存第一页的数据(不知道这个意义大不大?????)
DB:
道友可以在初始化项目(建表之后),运行下面sql插入模拟数据。
https://github.com/pgq10240817/PlayNews/tree/master/conf/db
频道数据: channels.sql
新闻:news3.sql
这个系列写到这里,基本上已经完结了,本来是计划10月份后写剩下的文章的,但是android框架那块搭建起来比较耗时。
后续的话其他系列应该会采用这个android框架来实验。
注意点:
1.model层次属性的修改最好通过setXX方式修改,不要直接Model.XX = YY方式去修改。
2.http post请求需要在content-type设置为application/json。
已知BUG:
暂无。等道友来填哈。