[[TOC]] == 一.基本约定 == {{{ 1.当接口处理正常时,HTTP STATUS CODE 返回给200。包括有正常的业务数据和数据为空的情况。 2.当接口处理异常时,HTTP STATUS CODE 返回给500,并且给出具体的错误信息。 { "uri" : "/intf/albums-by-type.jsp", "error-desc":"Need you follow uid.", "user-notice":"给用户的提示放在这里" }` 3.接口默认的字符编码是UTF-8,接口需要实现对req-enc和resp-enc参数的支持。在JSP的最顶部,实现类似下面的代码: String queryString = request.getQueryString(); String requestEncoding = getParam(queryString,"req_enc"); String responseEncoding = getParam(queryString,"resp_enc"); if(isNotBlank(requestEncoding)){ request.setCharacterEncoding(requestEncoding); } if(isNotBlank(responseEncoding)){ response.setCharacterEncoding(responseEncoding); } 4.所有有写操作的数据接口,必须用POST方式提交,在接口里需要判断提交方式,拒绝GET的调用请求。 5.接口中的JSON字符串,key都用双引号("")包裹,value是字符串类型时,也用双引号("")包裹;是数字类型时,不用引号。 }}} == 二.业务相关接口列表 == === 1.频道接口 (mrobot)=== {{{ URL: 作用: 提交方式:GET 参数:无 返回结果:JSON [ { "id":1, "img":"http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg", "title":"首页资讯", "view":"information-home/", "url":"" }, { "id":2, "img":"http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg", "title":"二胎政策", "view":"query-policy/", "url":"" }, { "id":3, "img":"http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg", "title":"二胎百科", "view":"encyclopedia/", "url":"" }, { "id":4, "img":"http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg", "title":"活动专区", "view":"activity/", "url":"" }, { "id":5, "img":"http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg", "title":"收藏", "view":"collection/", "url":"" }, { "id":6, "img":"http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg", "title":"设置", "view":"setting/", "url":"" } ] }}} === 2.资讯栏目接口 (mrobot)=== {{{ URL: 作用: 提交方式:GET 参数:无 返回结果:JSON { "channels": [ { "channelId": 22479, "name": "头条"//栏目名称 }, { "channelId": 22478, "name": "备孕"//栏目名称 }, { "channelId": 22479, "name": "孕育"//栏目名称 }, { "channelId": 22478, "name": "高龄产妇"//栏目名称 } ] } }}} === 3.资讯文章列表接口 (mrobot)=== {{{ URL: 作用: 提交方式:GET 参数: channelId-栏目id 返回结果:JSON { "data": [ { "id": "3473048", "image": "http://img0.pcauto.com.cn/pcauto/1311/25/g_3473048_1385345794838_240x160.jpg", "pubDate": "2013-11-25", "title": "标题", "type": 1, "url": "http://www.pcauto.com.cn/nation/347/3473048.html" }, { "id": "3473181", "image": "http://img0.pcauto.com.cn/pcauto/1311/25/g_3473181_1385343847663_240x160.jpg", "pubDate": "2013-11-25", "title": "标题", "type": 1, "url": "http://www.pcauto.com.cn/nation/347/3473181.html" } ], "focus": [ { "id": "3469260", "image": "http://img0.pcauto.com.cn/pcauto/guangzhou/2013/jsjx/1311/11243.jpg", "pubDate": "2013-11-25", "title": "标题", "topicUrl": "http://www.pcauto.com.cn/guangzhou/346/3469260.html", "url": "http://www.pcauto.com.cn/guangzhou/346/3469260.html" } ], "pageNo": 1, "pageSize": 20, "topData": [ { "id": "4245514", "image": "http://img0.pcauto.com.cn/pcauto/1311/25/3463325_chezhan.jpg", "pubDate": "2013-11-25", "seq": 4, "title": "标题", "to-uri": "pcautobrowser://bbs-topic/4245514", "type": 2 } ], "topFocus": [ { "cc-uri": "", "image": "http://imgad0.pcauto.com.cn/ivy/image/201311/7/13837866234700.jpg", "seq": 3, "title": "广告", "to-uri": "http://ivy.pcauto.com.cn/adpuba/click?adid=291573&id=auto.khd.zx.syjdt.", "vc-uri": "http://ivy.pcauto.com.cn/adpuba/show?adid=291573&id=auto.khd.zx.syjdt.&media=js" } ], "pageNo": 1, "pageSize": 20, "total": 298 } }}} === 4.资讯文章终端接口 (mrobot)=== {{{ URL: 作用:获取文章内容 提交方式:GET 参数: articleId-文章id 返回结果:HTML页面 同时在html源代码中加入以下内容,此为附加信息 url:用于获取评论的url title:文章的标题 firstPic:用于分享,文章终端的第一张图 }}} === 5.资讯文章评论接口 (mrobot)=== {{{ URL: 作用: 提交方式:GET 参数: 返回结果:JSON { "comments": [ { //没有引用其他评论的评论 "1": { //表达其引用关系的key "id":"24991904",//帖子id "name": "不是网易的江苏省盐城市网友 帅气飞扬: ", //用户名称 "floor": "1737", //楼层 "time": "2013-01-05 09:05:40", //时间 "content": "内容过于暴力,已和谐" //内容 }, "current":"1", //当前最外层引用标识 "support":"10086" //"顶"数量 "expand":false //判断是否展开,默认为false }, { "3": { "id":"24991804",//帖子id "name": "不是网易的江苏省盐城市网友 帅气飞扬: ", "floor": "1737", "time": "2013-01-05 09:05:40", "content": "内容过于暴力,已和谐" }, "2": { "id":"24941904",//帖子id "name": "不是网易的江苏省盐城市网友 帅气飞扬: ", "floor": "1737", "time": "2013-01-05 09:05:40", "content": "内容过于暴力,已和谐" }, "1": { "id":"24491904",//帖子id "name": "不是网易的江苏省盐城市网友 帅气飞扬: ", "floor": "1737", "time": "2013-01-05 09:05:40", "content": "内容过于暴力,已和谐" }, "4": { "id":"24993904",//帖子id "name": "不是网易的江苏省盐城市网友 帅气飞扬: ", "floor": "1737", "time": "2013-01-05 09:05:40", "content": "内容过于暴力,已和谐" }, "current":"4", "support":"10086" //顶数 "expand":false //判断是否展开,默认为false } ], "hot-comments": [ { //没有引用其他评论的评论 "1": { //表达其引用关系的key "id":"24691904",//帖子id "name": "不是网易的江苏省盐城市网友 帅气飞扬: ", //用户名称 "floor": "1737", //楼层 "time": "2013-01-05 09:05:40", //时间 "content": "内容过于暴力,已和谐" //内容 }, "current":"1" "support":"10086" //顶数 "expand":false //判断是否展开,默认为false } ] } }}} === 6.二胎政策接口 === {{{ URL: 作用: 提交方式:GET 参数: provinceId:省份id cityId:城市id districtId:区id 返回结果:JSON { "result":0,(0失败,1成功) "text":"广州尚未实施单独二胎政策", "articleList": [{ "id": "3473181", "title": "官方公告", "type": 1, "uri": "http://www.pcauto.com.cn/nation/347/3473181.html" }, { "id": "3473181", "title": "精彩推荐", "type": 2, "uri": "pcbabybrowser://information-channel/19?channelName=精彩推荐" }, { "id": "3473181", "title": "热门话题", "type": 3, "uri": "pcbabybrowser://information-channel/19?channelName=热门话题" }] } title和type固定, 精彩推荐,热门话题的uri根据文章栏目和帖子栏目改相应的id }}} === 7.地址查询接口 === {{{ URL: 作用: 提交方式:GET lastid:最新的id 参数: 返回结果:JSON 如果有更新,update为1,否则为0 { "lastid":123125, "update":1, "nodes":[ "id":1, "name":"广东", "nodes":[ "id":1, "name":"广州", "nodes":[ "id":1, "name":"天河" ] ] ] } { "last":123125, "update":0 } ps:先精确到区,如果有镇和街道的数据,则以此类推。 }}} === 8.(热门话题)帖子接口 (mrobot)=== {{{ URL: 作用: 提交方式:GET 参数: 返回结果:HTML页面 }}} === 9办证单位查询接口 === {{{ URL: 作用: 提交方式:GET 参数: provinceId:省份id cityId:城市id districtId:区id 返回结果:JSON { “city”:[ { "id":1, "name":"广州计生办", "address":"", "tel":"19986", "isSyn":1(1为同步到下级,0为否) }, { "id":1, "name":"广州居委会", "address":"", "tel":"19986", "isSyn":1 } ], “district”:[ { "id":1, "name":"广州天河区计生办", "address":"", "tel":"19986", "isSyn":1 }, { "id":1, "name":"广州天河区居委会", "address":"", "tel":"19986", "isSyn":1 } ], “street”:[ { "id":1, "name":"广州天河区新塘计生办", "address":"", "tel":"19986" }, { "id":1, "name":"广州天河区新塘居委会", "address":"", "tel":"19986" } ] } }}} === 9.1办事单位地点添加接口 === {{{ URL: 作用: 提交方式:POST 参数: provinceId:省份id cityId:城市id districtId:区id name:单位名称 address:地址 tel:联系电话 返回结果:JSON { “result”:1,(0失败,1成功) "msg":"提交成功" } }}} === 10.单独二胎政策实施时间添加接口 === {{{ URL: 作用: 提交方式:POST 参数: provinceId:省份id cityId:城市id districtId:区id date:实施时间,“2014-02-09”,格式 yyyy-MM-dd 返回结果:JSON { “result”:1,(0失败,1成功) "msg":"提交成功" } }}} === 11.办事指南接口 === {{{ URL: 作用: 提交方式:GET 参数: provinceId:省份id cityId:城市id districtId:区id 返回结果:HTML页面 点击步骤跳转协议:pcbadybrowser://procedure-detail/${id}?count=4&num=1 }}} === 12.办事指南详细解释接口 === {{{ URL: 作用: 提交方式:GET 参数: 返回结果:HTML页面 }}} === 13.办事指南纠错接口 === {{{ URL: 作用: 提交方式:POST 参数: "name":"", "address":"", "tel":"", "other":"" 返回结果:JSON { “result”:1,(0失败,1成功) "msg":"提交成功" } }}} === 14.精彩活动接口 === {{{ URL: 作用: 提交方式:GET 参数: 返回结果:HTML页面 }}} === 15.百科列表接口 === {{{ URL: 作用: 提交方式:GET 参数: “REQUEST_CODE” : int [请求代码] 返回结果:JSON { "RESPONSE_CODE": [ int返回代码, 与请求代码一致 ], "RESPONSE_STATUS”: [ int返回状态, 参考第三章.返回状态参数对照表 ], ”RESPONSE_INFO”{ "updateTime”: [ 时间戳此接口更新时间 ]"wikiSortCount”: [ int一级分类数量 ]"wikiSortList”[ { "wikiSortName”: [ string一级分类名 ]"isHaveSecondSort”: [ bool是否有二级分类 ]"wikiSortUrl”: [ string一级分类页对应url, 如果isHaveSecondSort为false必须提供 ]"wikiSecondSortCount”: [ int二级分类数量, 如果isHaveSecondSort为true必须提供 ]"wikiSecondSortList”  [ { 如果isHaveSecondSort为true必须提供"wikiSecondSortName”: [ string二级分类名 ]"isHaveThirdSort”: [ bool是否有三级分类 ]"wikiSecondSortUrl”: [ string二级分类页对应url, 如果isHaveSecondSort为false必须提供 ]"wikiThirdSortCount”: [ int三级分类数量如果isHaveSecondSort为true必须提供 ]"wikiThirdSortList”: [ { 如果isHaveSecondSort为true必须提供"wikiThirdSortName”: [ string三级分类名 ]"wikiThirdSortUrl”: [ string三级分类页对应url ] } ] } ] } ] } } }}} === 16.百科终端接口 === {{{ URL: 作用: 提交方式:GET 参数: 返回结果:HTML页面 }}} == 二.业务无关接口列表 == === 1.更新token接口 === {{{ URL: 作用: 提交方式:POST 参数: 二进制的压缩包 解释后参数名: provinceId:省份id cityId:城市id districtId:区id token:"a8b8a9d9c9ef1231"辨认设备的标记 返回结果:JSON HTTPSQS_PUT_ERROR:接收错误 HTTPSQS_PUT_OK:接收正常 PS:参照接口http://youpin.pchouse.com.cn/jsp/intf/update_user_token.jsp(许建有,杨孟君) }}} === 2.登录接口 === {{{ URL: 作用: 提交方式:POST username:用户名 password:密码 参数: 返回结果:JSON { "status": 0, "message": "ok", "session": "123456", "userId": 25520497, "common_session_id": "123456" } }}} === 3.ip定位接口 === {{{ URL: 作用: 提交方式:POST 参数: 返回结果:JSON { "result": 0 } }}}