跳到主要内容
版本:1.3.0

多端SDK API

投放渠道管理

投放类型

enum CHANNEL_TYPE {
INJECT_APP = "inject_app", // APP嵌入问卷
INJECT_WEB = "inject_web", // web嵌入问卷
INJECT_MP = "inject_mp", // 小程序嵌入问卷
}

渠道状态

enum CHANNEL_STATUS {
RECYCLING = 'recycling', // 回收中
PAUSE = 'pause' // 已暂停
}

创建投放渠道

POST /api/channel/create

Request

名称含义类型是否必填默认值
name渠道名称StringY
surveyId问卷idStringY
type渠道类型CHANNEL_TYPEY

请求示例

{
"name": "多端sdk投放",
"type": "inject_app",
"surveyId": "67cecfa87b4d3ae83aea1bd4"
}

返回示例

{
"code": 200,
"data": {
"channelId": "67e3c6c2ed29a79731c9e387"
}
}

获取渠道列表

POST /api/channel/getList

Request

名称含义类型是否必填默认值
surveyId问卷idStringY
curPage当前页码,从 1 开始numberY
pageSize每次获取数据numberN10

请求示例

{
"surveyId": "67cecfa87b4d3ae83aea1bd4",
"curPage": 1
}

返回示例

{
"code": 200,
"data": {
"list": [
{
"_id": "67e3c6c2ed29a79731c9e387",
"createdAt": "2025-03-26 17:20:02",
"updatedAt": "2025-03-26T09:20:02.620Z",
"ownerId": "663aebb52f2223c806b4c15d",
"surveyId": "67cecfa87b4d3ae83aea1bd4",
"name": "多端sdk投放",
"type": "inject_app",
"status": "recycling",
"currentUserId": "663aebb52f2223c806b4c15d",
"currentUse": "taoshuang",
"count": 0
}
],
"total": 1
}
}

更新投放渠道

POST /api/channel/update

Request

名称含义类型是否必填默认值
name渠道名称StringY
channelId渠道idStringY

请求示例

{
"channelId": "67e3c6c2ed29a79731c9e387",
"name": "sdk投放-测试"
}

返回示例

{
"code": 200
}

删除投放渠道

POST api/channel/delete

Request

名称含义类型是否必填默认值
channelId渠道idStringY

请求示例

{
"channelId": "67e3c6c2ed29a79731c9e387"
}

返回示例

{
"code": 200
}

sdk 接入相关

开放授权设计

appid和appSecret通过配置文件存储,若用于生产环境,请自行修改。

server/src/modules/appManager/appConfg.ts

export const APPList = [
{ appId: '2bAppid' },
];

sdk端上发起请求,需要在Header中携带appId和appToken,appToken通过getToken接口获取。

获取token

POST api/appManager/getToken

Request

名称含义类型是否必填默认值
appId应用idStringY

请求示例

{
"appId": "2bAppid"
}

返回示例

{
"code": 200,
"data": "eyJhbGciOiJIUzI1NiJ9.MmJBcHBpZA.0y_-HxkRGCDEFNkdQ1xsi41mH5u8J22836I5BWhibdM"
}

获取渠道详情

用于sdk查询渠道状态

GET /api/channel/find

Header

名称含义类型是否必填默认值
x-app-idappIdStringY
x-app-tokenappTokenStringY

Request

名称含义类型是否必填默认值
channelId渠道idStringY

请求示例

{
"channelId": "67c7f1a0315798a07a5a57e4"
}

返回示例

{
"code": 200,
"data": {
"_id": "67c7f1a0315798a07a5a57e4",
"createdAt": "2025-03-05T06:39:28.781Z",
"updatedAt": "2025-03-06T03:59:26.941Z",
"ownerId": "663aebb52f2223c806b4c15d",
"surveyId": "67c7f193315798a07a5a57dd",
"operatorId": "663aebb52f2223c806b4c15d",
"name": "11",
"type": "inject_app",
"status": "recycling",
"surveyPath": "WXJPhJYw"
}
}

获取问卷 schema

获取发布后的问卷数据 schema

get /api/responseSchema/getSchema

Request

名称含义类型是否必填默认值
surveyPath问卷短 IDStringY

请求示例

/api/responseSchema/getSchema?surveyPath=9VBpGNQi

返回示例

{
"success": true,
"data": {
"surveyMetaRes": {
"_id": "64c8bde289e41908d8898d13",
"name": "测试名字",
"surveyType": "normal",
"title": "问卷",
"curStatus": {
"status": "new",
"id": "new",
"date": 1690878454080
},
"createDate": 1690877410380
},
"surveyPublishRes": {
"_id": "64c8bde289e41908d8898d14",
"pageId": "64c8bde289e41908d8898d13",
"pageType": "normal",
"curStatus": {
"status": "new",
"id": "new",
"date": 1690877410471
},
"code": {
"bannerConf": {
"titleConfig": {
"mainTitle": "<h3 style=\"text-align: center\">2欢迎填写问卷</h3><p>为了给您提供更好的服务,希望您能抽出几分钟时间,将您的感受和建议告诉我们,<span style=\"color: rgb(204, 0, 0)\">期待您的参与!</span></p>",
"applyTitle": "让我们开始吧",
"subTitle": ""
},
"bannerConfig": {
"bgImage": "",
"videoLink": "",
"postImg": ""
},
"ruleConfig": {
"isShow": "",
"title": "问卷规则 》",
"ruleBottom": "0.5",
"color": "666666",
"content": ""
}
},
"scoreConf": {
"off": "",
"scoreShow": "",
"totalShow": "",
"random": "",
"showResult": "",
"allRight": "",
"ranNumber": "",
"totalScore": 0,
"scoreRange": [
{
"start": "",
"end": "",
"text": ""
}
]
},
"submitConf": {
"submitTitle": "提交",
"confirmAgain": {
"is_again": true,
"again_text": "确认要提交吗?"
},
"msgContent": {
"msg_200": "提交成功",
"msg_9001": "您来晚了,感谢支持问卷~",
"msg_9002": "请勿多次提交!",
"msg_9003": "您来晚了,已经满额!",
"msg_9004": "提交失败!"
},
"buttonList": [
{
"title": "",
"url": ""
}
],
"link": ""
},
"bottomConf": {
"bannerImage": "",
"bannerImageWidth": "100%",
"logoChoose": "didi",
"logoImage": "",
"logoImageWidth": "33%"
},
"baseConf": {
"begTime": "2018-05-22 17:17:48",
"endTime": "2028-05-22 17:17:48",
"viewType": "block",
"tLimit": "0",
"qEquipLimit": "0",
"qIpLimit": "0",
"loginLimit": {
"type": "",
"limit": "0"
},
"language": "chinese",
"formdataBackfill": "notallow",
"previousSwitch": "notallow",
"showVoteProcess": "allow",
"publishDate": 1527647912221
},
"skinConf": {
"skinColor": "#4a4c5b",
"inputBgColor": "ffffff"
},
"shareConf": {
"shareConfig": {
"shareTitle": "",
"shareDesc": "",
"shareImg": "",
"shareLink": ""
}
},
"dataConf": {
"dataList": [
{
"isRequired": true,
"showIndex": true,
"showType": true,
"showSpliter": true,
"type": "text",
"field": "data458",
"title": "标题1",
"titleRich": "标题1",
"placeholder": "",
"sLimit": 1,
"mobKey": "",
"randomSort": false,
"checked": false,
"exam": false,
"minNum": "",
"maxNum": "",
"options": [
{
"text": "选项1",
"imageUrl": "",
"others": false,
"mustOthers": false,
"othersKey": "",
"placeholderDesc": "",
"score": 0
},
{
"text": "选项2",
"imageUrl": "",
"others": false,
"mustOthers": false,
"othersKey": "",
"placeholderDesc": "",
"score": 0
}
],
"cOption": "",
"cOptions": [],
"score": 0,
"maxPhotos": 5,
"star": 5,
"timeStep": {
"hour": 1,
"min": 10
},
"nps": {
"leftText": "极不满意",
"rightText": "极满意"
},
"exclude": false,
"relTypes": {
"textarea": "多行文本框",
"text": "单行输入框"
},
"placeholderDesc": "",
"carDataType": 1,
"mhLimit": 0,
"matrixRadioOpt": {
"titles": [
{
"text": "标题1"
},
{
"text": "标题2"
}
]
},
"importKey": "single",
"importData": "",
"addressType": 3,
"isAuto": false,
"urlKey": "",
"cascadeData": [
{
"id": 0,
"name": "级联选项内容配置",
"children": [
{
"id": "cascade_0",
"name": "一级选项",
"children": [
{
"id": "cascade_0_0",
"name": "二级选项",
"children": [
{
"id": "cascade_0_0_0",
"name": "三级选项",
"children": []
}
]
}
]
}
]
}
],
"defaultProps": {
"children": "children",
"label": "name",
"id": "id"
},
"relyList": [
{
"relyField": "",
"relyOption": [],
"relyType": "selected"
}
],
"jumpTo": "",
"startDate": "",
"endDate": "",
"othersKeyMap": {}
},
{
"isRequired": true,
"showIndex": true,
"showType": true,
"showSpliter": true,
"type": "radio-v",
"relTypes": {
"radio-v": "竖向排列",
"radio-h": "横向排列"
},
"placeholderDesc": "",
"carDataType": 1,
"field": "data515",
"sLimit": 1,
"mhLimit": 0,
"mobKey": "",
"title": "标题2",
"titleRich": "标题2",
"placeholder": "",
"randomSort": false,
"checked": false,
"exam": false,
"minNum": "",
"maxNum": "",
"options": [
{
"text": "选项1",
"imageUrl": "",
"others": false,
"mustOthers": false,
"othersKey": "",
"placeholderDesc": "",
"score": 0
},
{
"text": "选项2",
"imageUrl": "",
"others": false,
"mustOthers": false,
"othersKey": "",
"placeholderDesc": "",
"score": 0
}
],
"matrixRadioOpt": {
"titles": [
{
"text": "标题1"
},
{
"text": "标题2"
}
]
},
"importKey": "single",
"importData": "",
"cOption": "",
"cOptions": [],
"score": 0,
"timeStep": {
"hour": 1,
"min": 10
},
"maxPhotos": 5,
"nps": {
"leftText": "极不满意",
"rightText": "极满意"
},
"star": 5,
"exclude": false,
"addressType": 3,
"isAuto": false,
"urlKey": "",
"cascadeData": [
{
"id": 0,
"name": "级联选项内容配置",
"children": [
{
"id": "cascade_0",
"name": "一级选项",
"children": [
{
"id": "cascade_0_0",
"name": "二级选项",
"children": [
{
"id": "cascade_0_0_0",
"name": "三级选项",
"children": []
}
]
}
]
}
]
}
],
"defaultProps": {
"children": "children",
"label": "name",
"id": "id"
},
"relyList": [
{
"relyField": "",
"relyOption": [],
"relyType": "selected"
}
],
"jumpTo": "",
"startDate": "",
"endDate": "",
"othersKeyMap": {}
}
],
"total": 0,
"activeIndex": 1,
"limitMap": {}
}
}
}
}
}

问卷提交接口

POST /api/surveyResponse/createResponseWithOpen

Header

名称含义类型是否必填默认值
x-app-idappIdStringY
x-app-tokenappTokenStringY

Request

名称含义类型是否必填默认值
surveyPath问卷短 IDStringY
channelId渠道idStringY
data问卷表单数据StringY
diffTime答题时长NumberN
clientTime客户端提交时间NumberN

请求示例

{
"surveyPath": "KdEfMuNZ",
"data": "{"data458":"223124325245","data515":"115019","data421":["067664","468683"]}",
"diffTime": 5701,
"clientTime": 1741161802180,
}

返回示例

{
"code": 200,
"success": true
}