| Version 3 (modified by yangbo, 14 years ago) (diff) |
|---|
亲子宝典APP项目接口
目录
1. 基本约定
1.当接口处理正常时,HTTP STATUS CODE 返回给200。包括有正常的业务数据和数据为空的情况。
2.当接口处理异常时,HTTP STATUS CODE 返回给500,并且给出具体的错误信息。
{
"uri" : "/intf/albums-by-type.jsp",
"error-code":"20502",
"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是字符串类型时,也用双引号("")包裹,并且过滤掉回车换行,对字符串中包含的双引号(")进行转义;是数字类型时,不用引号。
2. WEB接口
2.1 搜索百科
URL:/intf/search.jsp
HTTP请求方式:post
是否需要登录:是
功能说明:
提交参数:
req-enc:请求时字符编码,缺省是UTF-8
resp-enc:响应时字符编码,缺省是UTF-8
返回参数:
{
}
返回参数说明:
排序方式:
2.2 百科分类
URL:/intf/qzbk-types.jsp
HTTP请求方式:post
是否需要登录:是
功能说明:定义 http://www.pcbaby.com.cn/qzbd/ 上的层次关系,对层次关系的深度不作限制。
提交参数:
req-enc:请求时字符编码,缺省是UTF-8
resp-enc:响应时字符编码,缺省是UTF-8
返回参数:
{
"items": [
{
"id": 323,
"properties": {
"level": 0,
"seq": 1,
"name": "亲子百科",
"type": "node"
}
},
{
"id": 324,
"properties": {
"level": 1,
"seq": 2,
"name": "怀孕百科",
"type": "node"
}
},
{
"id": 326,
"properties": {
"level": 2,
"seq": 3,
"name": "生男生女",
"type": "article"
}
}
],
"relations": {
"$node id value1": [423,34,344,3434],
"$node id value2": [423,34,344,3434]
}
}
返回参数说明:
id:节点ID
level:节点的层次,1表示根节点。
seq:节点的顺序,同级节点之间的显示顺序。从1开始
name:节点名称
type:节点类型,node表示该节点的下级还是一个节点,article表示该节点的下级已经是文章id
排序方式:
修改历史
2012-08-20:
-创建
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/hr/2009/global/images/logo.gif)