[[TOC]] == 一.基本约定 == {{{ 1.基本约定 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.0首页 === {{{ 备注:首页 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: status:1备孕,2怀孕,3育儿 weeks:第几周 返回参数: { focus:[ { id: image: title: type:论坛(1列表、2终端);亲子学院(3列表、4终端);活动(5列表、6终端);工具(7终端);食谱(8终端);资讯(9终端);问答(10终端);百科(11终端) } ], recommend:[ { id: image: title: type:论坛(1列表、2终端);亲子学院(3列表、4终端);活动(5列表、6终端);工具(7终端);食谱(8终端);资讯(9终端);问答(10终端);百科(11终端) } ], hotChannels:[ { id: name: type: image: } ] } }}} === 2.0工具 === ==== 2.1工具首页 ==== {{{ 备注:工具类首页 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:html页面 缓存方式:无 缓存时间:无 请求参数: 协议: 点击二胎政策查询,pcbabybible://policy-search 点击备孕日历,pcbabybible://pregnancy-calendar 点击其他工具,正常HTTP协议 }}} ==== 2.2其他工具 ==== {{{ 备注:其他工具 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:html页面 缓存方式:无 缓存时间:无 请求参数: }}} === 3.0每日知识 === ==== 3.0每日知识首页 ==== {{{ 备注:每日知识首页 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: status:1备孕,2怀孕,3育儿 weeks:第几周 返回参数: { tips:"", ad:"", cookbook:[ { id: image: title: des: } ], timeline:[ { "title":"优生优育", "section":[ { id: image: title: type:论坛(1列表、2终端);亲子学院(3列表、4终端);活动(5列表、6终端);工具(7终端);食谱(8终端);资讯(9终端);问答(10终端);百科(11终端) }, { id: image: title: type: } ] }, { "title":"生男生女", "section":[ { id: image: title: type: }, { id: image: title: type: } ] } ] } }}} ==== 3.1周期 ==== {{{ 备注:周期 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: status:1备孕,2怀孕,3育儿 返回参数: { weeks:[ { num:1, tips:"多吃含钙食物" }, { num:1, tips:"多吃含tie食物" } ] } }}} ==== 3.1食谱列表 ==== {{{ 备注:食谱列表 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: status:1备孕,2怀孕,3育儿 type:1每日知识,2食谱 weeks:第几周 返回参数 { id: cookbook:[ [//第一天 { id: name: image: des: time:(早餐,午餐、晚餐) }, { id: name: image: des: time:(早餐,午餐、晚餐) }, { id: name: image: des: time:(早餐,午餐、晚餐) } ], [//第二天 { id: name: image: des: time:(早餐,午餐、晚餐) }, { id: name: image: des: time:(早餐,午餐、晚餐) }, { id: name: image: des: time:(早餐,午餐、晚餐) } ] ] } }}} ==== 3.2食谱详情 ==== {{{ 备注:食谱详情 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: id:食谱id 返回参数 { id: name: picDes:[ { id: image: des: } ] } }}} ==== 3.2文章搜索 ==== {{{ 备注:文章搜索 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: id:食谱id 返回参数 { datas:[ { "cmtCount": 0, "id": "1455932", "image": "http://img0.pcbaby.com.cn/pcbaby/2tai/beiyun/zhunbei/1404/beiyun1-184128_1.jpg", "pubDate": "2014-03-27 11:56:18", "title": "为啥二胎比一胎难怀?解密真相", "url": "http://2tai.pcbaby.com.cn/145/1455932.html" } ] } }}} === 4.0交流圈 === ==== 4.1生活圈帖子列表 ==== {{{ 备注:生活圈帖子列表,时间倒序 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: channelId:当id为0时,为全部栏目的最新帖子 type:hot精华,new最新, pageNo: pageSize: 返回参数 { id: name: topics:[ { id: images:[ "http://1", "http://2", "http://3", ], title: sum: author: time:时间戳 collectedNum: commentNum: } ] } }}} ==== 4.2生活圈栏目列表 ==== {{{ 备注:生活圈栏目列表 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数 { id: channels:[ { id: name: image: des: } ] } }}} ==== 4.3帖子终端 ==== {{{ 备注:获取帖子内容 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:html页面 缓存方式:无 缓存时间:无 请求参数: tid: pageNo:页码 pageSize:一页条数 设置header Cookie = "common_session_id=xxxx"; 返回参数 加入一段注释,注释内的内容为一段json /*@_HTML_META_START_ {"favoriteId":-1,"pageCount":5,"pageNo":1,"title":"3月6日北京提2012款白色三厢2.0AT旗舰型作业","userId":32031278,"webUrl":"http://bbs.pcauto.com.cn/topic-4592911.html"} _HTML_META_END_@*/ 点击图片,要有对应协议,可以参考接口: http://mrobot.pcauto.com.cn/v2/bbs/topics/4592911?pageNo=1&pageSize=19&picRule=2&authorId=0&topicTemplate=4.0.0&app=pcautobrowser&size=18 url:http://piebbs.pconline.com.cn/rest/topics/${topicId} }}} ==== 4.4帖子是否已收藏 ==== {{{ 备注:帖子是否已收藏 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: tid: 设置header Cookie = "common_session_id=xxxx"; 返回参数 { msg: result } }}} ==== 4.5回帖、发帖 ==== {{{ 备注:回帖、发帖 请求URL:http:// HTTP请求方式:post 是否需要登录:是 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: agent:1待验证 message = 内容; replyToId = 回帖楼层id tag:1性福,2婆媳,3情感,4职场,5姐妹,6邻里 设置header Cookie = "common_session_id=xxxx"; 返回参数 { msg: result: } }}} ==== 4.6上传图片 ==== {{{ 备注:上传图片 请求URL:http://upc.pconline.com.cn/upload_quick.jsp?application=yidong HTTP请求方式:post 是否需要登录:是 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: file:文件名称,文件本体 富文本格式传送,该接口返回图片url,其被用于回帖或者发帖中贴图。 }}} ==== 4.7私密圈帖子列表 ==== {{{ 备注:私密圈帖子,时间倒序 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: type:1私语,2话题 返回参数 { id: name: topics:[ { id: title: des: author: time: collectedNum: commentNum: type:1性福,2婆媳,3情感,4职场,5姐妹,6邻里 } ] } }}} ==== 4.8私密圈闺蜜帖子列表 ==== {{{ 备注:私密圈闺蜜帖子,时间倒序 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数 { id: name: topics:[ { id: image:"" title: des: author: time: collectedNum: commentNum: type:1性福,2婆媳,3情感,4职场,5姐妹,6邻里 replyContent:回复内容 replyAuthorName: replyAuthorId: replyTime: } ] } }}} === 5.0问答 === ==== 5.1问答搜索 ==== {{{ 备注:问答搜索 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: keyword:关键字 pageNo pageSize 返回参数 { id: name: questions:[ { id: question:"" answer:"" authorId: authorFace: authorName: hospital: department: time: } ] } }}} ==== 5.2问答详情 ==== {{{ 备注:问答详情 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:HTML页面 缓存方式:无 缓存时间:无 请求参数: id:问题id 返回参数: }}} ==== 5.3提问 ==== {{{ 备注:提问 请求URL:http:// HTTP请求方式:post 是否需要登录:是 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: title:问题标题 des = 问题描述; typeId = 问题分类id specialistId:专家id,可选 设置header Cookie = "common_session_id=xxxx"; 返回参数 { msg: result: } }}} ==== 5.4问题分类 ==== {{{ 备注:问题分类 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数 { sections:[ { id: name:备孕 types:[ { id:1 name:生男生女 }, { id:2 name:孕前饮食 } ] }, { id: name:月子 types:[ { id:1 name:生男生女 }, { id:2 name:孕前饮食 } ] } ] } }}} === 6.0 个人中心 === ==== 6.1我的消息数 ==== {{{ 备注:我的消息数--非论坛部分 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数 { myAnswerCount:我的问答数 myCollectionCount:我的收藏数 answerReply:问答回复数 articleReply:文章回复数 } }}} ==== 6.1我的消息数2 ==== {{{ 备注:我的消息数--论坛部分 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数 { myTopicsCount:我的圈子数 topicsReplyCount:圈子回复数 } }}} ==== 6.2我的交流圈-主贴、精华帖 ==== {{{ 备注:我的交流圈-主贴、精华帖 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: type:1主题,2精华帖 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { id: name: topics:[ { id: title: des: author: time: collectedNum: commentNum: } ] } }}} ==== 6.3我的交流圈-回帖 ==== {{{ 备注:我的交流圈-回帖 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { id: name: topics:[ { id: image:"" title: des: author: time: collectedNum: commentNum: type:1性福,2婆媳,3情感,4职场,5姐妹,6邻里,7私语,8话题 replyContent:回复内容 replyAuthorName: replyAuthorId: replyTime: } ] } }}} ==== 6.3.1我的交流圈数量 ==== {{{ 备注:我的交流圈-主贴、精华帖 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; 返回参数 { topicCount:主贴数量 hotTopicCount:精华帖数量 replyTopicCount:回帖数量 } }}} ==== 6.4我的问答 ==== {{{ 备注:我的问答 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: type:1已解决,2未解决 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { questions:[ { id: image:"" title: des: time: } ] } }}} ==== 6.4.1我的问答数量 ==== {{{ 备注:我的问答 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; 返回参数 { solvedCount:已解决数量 unsolvedCount:未解决数量 } }}} ==== 6.5我的收藏 ==== {{{ 备注:我的收藏 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: type:1文章 2帖子 3百科 4问答 5课程 6食谱 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { collections:[ { id: title: des: } ] } }}} ==== 6.5.1是否已收藏 ==== {{{ 备注:是否已收藏 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: type:1文章 2帖子 3百科 4问答 5课程 6食谱 设置header Cookie = "common_session_id=xxxx"; id: 返回参数 { msg: result: } }}} ==== 6.6删除收藏 ==== {{{ 备注:删除收藏 请求URL: HTTP请求方式:post 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; token:设备唯一号 id: type:1文章 2帖子 3百科 4问答 5课程 6食谱 返回参数 { msg: result: } }}} ==== 6.7添加收藏 ==== {{{ 备注:添加收藏 请求URL: HTTP请求方式:post 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; token:设备唯一号 id: type:1文章 2帖子 3百科 4问答 5课程 6食谱 title: 返回参数 { msg: result: } }}} ==== 6.8圈子回复-主贴 ==== {{{ 备注:圈子回复-主贴回复 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { id: name: topics:[ { id: image:"" title: des: author: time: collectedNum: commentNum: type:1性福,2婆媳,3情感,4职场,5姐妹,6邻里,7私语,8话题 replyContent:回复内容 replyAuthorName: replyAuthorId: replyTime: } ] } }}} ==== 6.9圈子回复-回帖回复 ==== {{{ 备注:圈子回复-回贴回复 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { id: name: topics:[ { id: image:"" title: des: author: time: collectedNum: commentNum: type:1性福,2婆媳,3情感,4职场,5姐妹,6邻里,7私语,8话题 myContent:我发的内容 replyContent:回复内容 replyAuthorName: replyAuthorId: replyTime: } ] } }}} ==== 6.10问答回复 ==== {{{ 备注:问答回复 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { id: name: answers:[ { id: question:"" answer:"" authorId: authorFace: authorName: hospital: department: time: } ] } }}} ==== 6.11文章回复 ==== {{{ 备注:文章回复 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 设置header Cookie = "common_session_id=xxxx"; pageNo pageSize 返回参数 { id: name: comments:[ { id: title:"" authorId: authorFace: authorName: replyContent: content: time: articleId: } ] } }}} === 7.0亲子学院 === ==== 7.1亲子学院首页列表 ==== {{{ 备注:亲子学院首页列表 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数 { sections:[ { title:"最新课程", course:[ { title:"怀孕前需要做的检查", image:"", id: } ] } ] } }}} ==== 7.2亲子学院搜索 ==== {{{ 备注:亲子学院搜索 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: pageNo pageSize 返回参数 { course:[ { title:"怀孕前需要做的检查", image:"", id: } ] } }}} ==== 7.3课程详情 ==== {{{ 备注:亲子学院课程详情 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: id:课程id 返回参数 { id: title:"怀孕前需要做的检查", image:"", des:"视频简介", url: id: expertId: expertName: expertDes:"", expertFace:"", hospital: positionalTitles:职称 } }}} ==== 7.4相关问答 ==== {{{ 备注:相关问答 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: id:专家id pageNo pageSize 返回参数 { id: name: questions:[ { id: question:"" answer:"" authorId: authorFace: authorName: hospital: department: time: } ] } }}} ==== 7.5专家介绍 ==== {{{ 备注:专家介绍 请求URL: HTTP请求方式:get 是否需要登录:否 返回格式:HTML页面 缓存方式:无 缓存时间:无 请求参数: id:专家id pageNo pageSize 点击协议 向TA提问按钮点击协议 pcbabybible://ask-expert/id }}} ==== 7.6视频介绍 ==== {{{ 备注:视频介绍 请求URL:http:// HTTP请求方式:get 是否需要登录:否 返回格式:html页面 缓存方式:无 缓存时间:无 请求参数: pageNo pageSize }}} === 8.0活动 === ==== 8.1活动首页 ==== {{{ 备注:活动首页 请求URL:http://www.pcbaby.com.cn/huodong/list/ HTTP请求方式:get 是否需要登录:否 返回格式:JSON 缓存方式:无 缓存时间:无 请求参数: 返回参数: { "RESPONSE_CODE": 304, "RESPONSE_STATUS": 100, "RESPONSE_INFO": { "eventListCount": 2, "eventList": [ { "eventTime": "2014年5月29日—6月15日", "eventTitle": "端午知识大竞赛 拼智慧赢好礼", "imgUrl": "http://img0.pcbaby.com.cn/pcbaby/huodong/list/1405/580x230.jpg", "eventUrl": "http://play9.pcbaby.com.cn/baby140529/index.jsp" } ] } } }}} === 9.0二胎政策 === {{{ 2胎政策部分使用接口文档: http://trac.pc.com.cn/iphone/wiki/2ndchild/interface }}} ==== 9.1 一胎怀孕文章栏目 ==== {{{ URL:http://mrobot.pcbaby.com.cn/configs/pcbaby_1tai_cms_iphone_channel_tree 作用:资讯栏目 提交方式:GET 参数:无 返回结果:JSON { "channels": [ { "id": 1, "title": "头条" }, { "id": 2, "title": "备孕" }, { "id": 3, "title": "孕育" }, { "id": 5, "title": "育儿" } ] } }}}