wiki:2ndchild/interface

Version 28 (modified by hejingdong, 12 years ago) (diff)

--

一.基本约定

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:http://mrobot.pcauto.com.cn/configs/pcbaby_2tai_left_menu
作用:
提交方式:GET
参数:无
返回结果:JSON

[
    {
        "id": 1,
        "img": "http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg",
        "title": "首页资讯",
        "view": "baby-information/",
        "url": ""
    },
    {
        "id": 2,
        "img": "http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg",
        "title": "二胎政策",
        "view": "baby-policy/",
        "url": ""
    },
    {
        "id": 3,
        "img": "http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg",
        "title": "二胎百科",
        "view": "baby-encyclopedia/",
        "url": ""
    },
    {
        "id": 4,
        "img": "http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg",
        "title": "活动专区",
        "view": "baby-activity/",
        "url": ""
    },
    {
        "id": 5,
        "img": "http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg",
        "title": "收藏",
        "view": "baby-collection/",
        "url": ""
    },
    {
        "id": 6,
        "img": "http://img0.pcauto.com.cn/pcauto/1310/16/3233041_Img388290093_thumb.jpg",
        "title": "设置",
        "view": "baby-setting/",
        "url": ""
    }
]

2.资讯栏目接口 (mrobot)

URL:http://mrobot.pcbaby.com.cn/configs/pcbaby_2tai_cms_iphone_channel_tree
作用:
提交方式:GET
参数:无
返回结果:JSON
{
    "channels": [
        {
            "id": 1,
            "title": "头条"
        },
        {
            "id": 2,
            "title": "备孕"
        },
        {
            "id": 3,
            "title": "孕育"
        },
        {
            "id": 4,
            "title": "高龄产妇"
        }
    ]
}

3.资讯文章列表接口 (mrobot)

URL:http://mrobot.pcbaby.com.cn/v2/cms/channels/1
作用:
提交方式: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:http://mrobot.pcbaby.com.cn/v3/cms/articles/1275094?pageNo=1
作用:获取文章内容
提交方式:GET
参数:
  articleId-文章id
返回结果:HTML页面
同时在html源代码中加入以下内容,此为附加信息
<!-- 
/*@_HTML_META_START_    
{"url":"http://best.pconline.com.cn/discovery_art.jsp?topicId=3064","title":"东芝 3TB DT01ACA300 7200转 64M SATA3 台式机硬盘","firstPic":"http://img.pconline.com.cn/images/upload/upc/tx/pc_best/1309/02/c0/25177373_1378101718895_350x350.jpg"}
_HTML_META_END_@*/
 -->
url:用于获取评论的url
title:文章的标题
firstPic:用于分享,文章终端的第一张图

5.资讯文章评论接口 (mrobot)

URL:http://mrobot.pcbaby.com.cn/v3/cmt/new_topics/12958224?articleId=1147610&reverse=0&pageNo=1&pageSize=20#
作用:
提交方式:GET
参数:
返回结果:JSON
{
  "comments": [
    {  //没有引用其他评论的评论
      "1": { //表达其引用关系的key
        "id":"24991904",//帖子id
        "name": "不是网易的江苏省盐城市网友&nbsp;帅气飞扬: ",  //用户名称
        "floor": "1737",  //楼层
        "time": "2013-01-05 09:05:40",  //时间
        "content": "内容过于暴力,已和谐" //内容
      },
      "current":"1",               //当前最外层引用标识
      "support":"10086"       //"顶"数量
      "expand":false  //判断是否展开,默认为false
    },
    {
      "3": {
        "id":"24991804",//帖子id
        "name": "不是网易的江苏省盐城市网友&nbsp;帅气飞扬: ",
        "floor": "1737",
        "time": "2013-01-05 09:05:40",
        "content": "内容过于暴力,已和谐"
      },
      "2": {
        "id":"24941904",//帖子id
        "name": "不是网易的江苏省盐城市网友&nbsp;帅气飞扬: ",
        "floor": "1737",
        "time": "2013-01-05 09:05:40",
        "content": "内容过于暴力,已和谐"
      },
      "1": {
        "id":"24491904",//帖子id
        "name": "不是网易的江苏省盐城市网友&nbsp;帅气飞扬: ",
        "floor": "1737",
        "time": "2013-01-05 09:05:40",
        "content": "内容过于暴力,已和谐"
      },
      "4": {
        "id":"24993904",//帖子id
        "name": "不是网易的江苏省盐城市网友&nbsp;帅气飞扬: ",
        "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": "不是网易的江苏省盐城市网友&nbsp;帅气飞扬: ",  //用户名称
        "floor": "1737",  //楼层
        "time": "2013-01-05 09:05:40",  //时间
        "content": "内容过于暴力,已和谐" //内容
      },
      "current":"1"
      "support":"10086" //顶数
      "expand":false  //判断是否展开,默认为false
    }
  ]
}

6.二胎政策接口

URL:http://dev7.pcbaby.com.cn:8004/intf/app/policy.jsp
作用:
提交方式:GET
参数:
areaId:地区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/${channelid}?channelName=精彩推荐"
    }, {
      "id": "3473181",
      "title": "热门话题",
      "type": 3,
      "uri": "pcbabybrowser://topics-list/${channelid}?channelName=热门话题"
    }]
}

title和type固定,
精彩推荐,热门话题的uri根据文章栏目和帖子栏目改相应的id

7.地址查询接口

URL:http://dev7.pcbaby.com.cn:8004/intf/app/area.jsp
作用:
提交方式: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:http://mrobot.pcbaby.com.cn/v2/bbs/topics/1647307?pageNo=1&pageSize=20&picRule=0&app=pcbabybrowse
作用:
提交方式:GET
参数:
返回结果:HTML页面

9办证单位查询接口

URL:http://dev7.pcbaby.com.cn:8004/intf/app/office.jsp
作用:
提交方式:GET
参数:
areaId:地区id
返回结果:JSON
{
   “city”:[
    {
      "id":1,
      "name":"广州计生办",
      "address":"",
      "tel":"19986",
"phone":"",
      "type":1
    }, {
      "id":1,
      "name":"广州居委会",
      "address":"",
      "tel":"19986",
"phone":"",
      "type":1
    }
  ],
   “district”:[
    {
      "id":1,
      "name":"广州天河区计生办",
      "address":"",
      "tel":"19986",
      "type":1
    }, {
      "id":1,
      "name":"广州天河区居委会",
      "address":"",
      "tel":"19986",
      "type":1
    }
  ],
   “street”:[
    {
      "id":1,
      "name":"广州天河区新塘计生办",
      "address":"",
      "tel":"19986",
      "type":1
    }, {
      "id":1,
      "name":"广州天河区新塘居委会",
      "address":"",
      "tel":"19986",
      "type":1
    }
  ]
}

9.1办事单位地点添加接口

URL:
作用:
提交方式:POST
参数:
areaId:地区id
name:单位名称
address:地址
tel:联系电话
返回结果:JSON
{
“result”:1,(0失败,1成功)
"msg":"提交成功"
}

10.单独二胎政策实施时间添加接口

URL:
作用:
提交方式:POST
参数:
areaId:地区id
date:实施时间,“2014-02-09”,格式 yyyy-MM-dd
返回结果:JSON
{
“result”:1,(0失败,1成功)
"msg":"提交成功"
}

11.办事指南接口

URL:
作用:
提交方式:GET
参数:
areaId:省份id
返回结果:HTML页面
点击步骤跳转协议:pcbadybrowser://procedure-detail/${id}?count=4&num=1&areaId=${areaId}
点击文章跳转协议:pcbabybrowser://information-article/1276412
点击帖子跳转协议:pcbabybrowser://bbs-topic/4337761

12.办事指南详细解释接口

URL:
作用:
提交方式:GET
参数:
返回结果:HTML页面
点击纠错跳转协议:pcbadybrowser://correction/${id}
点击办证材料:pcbadybrowser://baby-webview/?url=http://xxxx

12.1办证材料详细解释接口

URL:
作用:
提交方式:GET
参数:
返回结果:HTML页面

13.办事指南纠错接口

URL:
作用:
提交方式:POST
参数:
"id":
"name":"",
"address":"",
"tel":"",
"other":""
返回结果:JSON
{
“result”:1,(0失败,1成功)
"msg":"提交成功"
}

14.精彩活动接口

URL:
作用:
提交方式:GET
参数:
返回结果:HTML页面
网页跳转协议:pcbadybrowser://baby-full-webview/?url=http://xxxx

15.百科列表接口

URL:http://baike.pcbaby.com.cn/intf/app/content_wiki_308.jsp
   
作用:
提交方式:GET
参数:
  “REQUEST_CODE” : 308 [请求代码]
返回结果: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
     ]
   }
    ]
  }
   ]
 }
  ]
}
}

15.1百科是否有更新

URL:http://baike.pcbaby.com.cn/intf/app/content_wiki_update_309.jsp
作用:百科是否有更新
提交方式:GET
{
“REQUEST_CODE” : 309 [请求代码]
}
参数:
返回结果:JSON
“RESPONSE_CODE”  :  [int 返回代码,与请求代码一致]
“RESPONSE_STATUS”:  [int返回状态,参考第三章.返回状态参数对照表]]
”RESPONSE_INFO” 
{
	“updateTime”:[时间戳 此接口更新时间]
}
  

15.2百科搜索

URL:http://baike.pcbaby.com.cn/intf/app/content_wiki_search_310.jsp
作用:百科搜索
ps:因为此接口搜索内容为接口15的第四级内容,iOS和android端均使用本地搜索代替,此接口暂时无用
提交方式:GET
{
“REQUEST_CODE” : 310 [请求代码]
“keywords”:[string 搜索的关键字]
}
参数:
返回结果:JSON
“RESPONSE_CODE”  :  [int 返回代码,与请求代码一致]
“RESPONSE_STATUS”:  [int返回状态,参考第三章.返回状态参数对照表]]
”RESPONSE_INFO” 
{
“wikiThirdSortList”:
[{
		“wikiThirdSortName”:[string 三级分类名]
“wikiThirdSortUrl”:[string 三级分类页对应url]
}]
}

15.3状态返回

返回状态参数对照表

描述RESPONSE_INFO缩写值RESPONESE_STATUS
成功RESPONSE_STATUS_OK100
失败RESPONSE_STATUS_FAIL500
请求Json格式错误RESPONSE_STATUS_JSON_ERROR501
没有操作权限RESPONSE_STATUS_NOPERMISSION401
不可识别命令RESPONSE_STATUS_UNRECOGNIZED402
参数错误RESPONSE_STATUS_PARAMERROR403

16.百科终端接口

URL:
作用:
提交方式:GET
参数:
返回结果:HTML页面

二.业务无关接口列表

1.更新token接口

URL:
作用:
提交方式:POST
参数:
  二进制的压缩包
解释后参数名:
areaId:地区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:http://whois.pconline.com.cn/ipJson.jsp?level=3
作用:
提交方式:POST
参数:
level:可指定输出结果的精度,=1/=2/=3分别代表只输出省名称/输出省市名称/输出省市区名称 
ps:暂时测试可知,市名可确定,但区名不一定可以
返回结果:JSON
{
  "ip": "14.23.114.34",
  "pro": "广东省",
  "city": "广州市",
  "region": "",
  "addr": "广东省广州市",
  "regionNames": ""
}