查詢頻道問卷題目與結果
更新時間:2022-09-02 18:08:07
介面描述
1、查询频道问卷题目与结果
2、问卷ID可以从获取频道问卷列表中获取
3、接口支持https协议
介面URL
http://api.polyv.net/live/v3/channel/questionnaire/detail
請求方式
GET
介面限制
1、介面同時支援HTTP、HTTPS,建議使用HTTPS確保介面安全,介面呼叫有頻率限制,詳細請查看
請求參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | true | String | 帳號appId【詳見取得金鑰】 |
| timestamp | true | Long | 目前13位毫秒級時間戳記,3分鐘內有效 |
| sign | true | String | 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則】 |
| channelId | true | String | 頻道號 |
| questionnaireId | true | String | 問卷id,該參數取得自【查詢頻道問卷列表】 |
範例
https://api.polyv.net/live/v3/channel/questionnaire/detail?appId=frlr1zazn3&sign=21B0DC009E318AA78636A7CE9C622056&questionnaireId=fwndt7vq4x&channelId=1965681×tamp=1621845043008
回應參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 回應狀態碼,200為成功返回,非200為失敗【詳見全域錯誤說明】 |
| status | String | 回應狀態文字資訊 |
| message | String | 回應描述資訊,當code為400或500時,輔助描述錯誤原因 |
| data | Object | 成功回應時為問卷基本資訊 【詳見data欄位說明】 |
data欄位說明
| 參數名 | 類型 | 說明 |
|---|---|---|
| questionnaireId | String | 問卷ID |
| customQuestionnaireId | String | 使用者自訂問卷ID |
| channelId | String | 頻道號 |
| userId | String | 使用者ID |
| name | String | 問卷名稱 |
| status | String | 問卷狀態 draft:草稿 send:已發送 delete:已刪除 |
| createdTime | Long | 問卷建立時間 |
| endTime | Long | 停止問卷時間 |
| questions | Array | 問卷問題列表 【詳見questions欄位說明】 |
questions欄位說明
| 參數名 | 類型 | 說明 |
|---|---|---|
| questionId | String | 問題ID |
| channelId | String | 頻道號 |
| userId | String | 使用者ID |
| name | String | 問題題目 |
| type | String | 問題類型 R:單選 C:多選 S:評星題 Q:問答 |
| option 1~10 | String | 選項A~J的內容 |
| createdTime | String | 建立時間 |
| lastModified | String | 最後修改時間 |
| answer | String | 問題答案 |
| note | String | 備註 |
| templateId | String | 範本Id |
| status | String | 問卷狀態 draft:草稿 send:已發送 delete:已刪除 |
| times | Integer | 問卷發起次數 |
| tips1 1~5 | String | 題目對應的提示 |
| required | String | 是否必填 Y:必填 N:非必填 |
| scoreEnabled | String | 是否計分 Y:計分 N:不計分 |
| score | String | 題目分值 |
| itemType | Integer | 答題類型 1:問答 0:答題卡 |
Java請求範例
快速接入基礎代碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下載檔案中。
強烈建議您使用直播Java SDK完成API的功能對接,直播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
private static final Logger log = LoggerFactory.getLogger(LiveInteractionTest.class);
/**
* 查询频道问卷题目与结果
* @throws IOException
*/
@Test
public void testGetQuestionnaireDetail() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId=super.appId;
String appSecret=super.appSecret;
String userId = super.userId;
String timestamp=String.valueOf(System.currentTimeMillis());
//业务参数
String channelId = "1965681";
String questionnaireId = "fwndt7vq4x";
String url = "http://api.polyv.net/live/v3/channel/questionnaire/detail";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("channelId",channelId);
requestMap.put("questionnaireId",questionnaireId);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url,requestMap);
log.info("测试查询频道问卷题目与结果接口返回值:{}",response);
//do somethings
}
回應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"code": 200,
"status": "success",
"message": "",
"data": {
"questionnaireId": "fwndt7vq4x",
"channelId": 1965681,
"userId": "1b448be323",
"name": "测试试卷,明天会更好调查2 (1175)",
"status": "saved",
"createdTime": 1615507307000,
"lastModified": 1615507307000,
"endTime": null,
"customQuestionnaireId": "30231311ed334a7f80e4db520b3bec99",
"questions": [{
"questionId": "4bb657cc5897451ea4705a9bb843e16c",
"channelId": 1965681,
"userId": "1b448be323",
"name": "您的兴趣爱好?",
"type": "C",
"option1": "篮球",
"option2": "足球",
"option3": "排球",
"option4": "跑步",
"option5": "羽毛球",
"createdTime": 1615507307000,
"lastModified": 1615507307000,
"answer": "a",
"note": null,
"templateId": null,
"status": "draft",
"times": 0,
"tips1": null,
"tips2": null,
"tips3": null,
"tips4": null,
"tips5": null,
"required": "Y",
"scoreEnabled": "Y",
"option6": null,
"option7": null,
"option8": null,
"option9": null,
"option10": null,
"score": 20,
"itemType": 0,
"option11": null,
"option12": null,
"option13": null,
"option14": null,
"option15": null
}, {
"questionId": "b5b33c428cfd488eb8f4c5991e4e9aff",
"channelId": 1965681,
"userId": "1b448be323",
"name": "您的性别",
"type": "R",
"option1": "M",
"option2": "W",
"option3": null,
"option4": null,
"option5": null,
"createdTime": 1615507307000,
"lastModified": 1615507307000,
"answer": "",
"note": null,
"templateId": null,
"status": "draft",
"times": 0,
"tips1": null,
"tips2": null,
"tips3": null,
"tips4": null,
"tips5": null,
"required": "Y",
"scoreEnabled": "N",
"option6": null,
"option7": null,
"option8": null,
"option9": null,
"option10": null,
"score": null,
"itemType": 0,
"option11": null,
"option12": null,
"option13": null,
"option14": null,
"option15": null
}, {
"questionId": "cc4b8c4c44d346bcab4bb47e3dca275d",
"channelId": 1965681,
"userId": "1b448be323",
"name": "您的职务?",
"type": "Q",
"option1": "",
"option2": null,
"option3": null,
"option4": null,
"option5": null,
"createdTime": 1615507307000,
"lastModified": 1615507307000,
"answer": "",
"note": null,
"templateId": null,
"status": "draft",
"times": 0,
"tips1": null,
"tips2": null,
"tips3": null,
"tips4": null,
"tips5": null,
"required": "Y",
"scoreEnabled": "N",
"option6": null,
"option7": null,
"option8": null,
"option9": null,
"option10": null,
"score": null,
"itemType": 0,
"option11": null,
"option12": null,
"option13": null,
"option14": null,
"option15": null
}]
}
}
異常範例
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
