private final Logger log = LoggerFactory.getLogger(getClass());
/**
* 新增自定义字段
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void createLabelTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "https://api.polyv.net/live/v4/user/custom-field/viewer-value/save";
String viewerId = "viewerId";
String customFieldId = "PAY_STATUS";
String customFieldValue = "已支付";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
Map<String, Object> customFieldMap = new HashMap<>();
customFieldMap.put("viewerId", viewerId);
customFieldMap.put("customFieldId", customFieldId);
customFieldMap.put("customFieldValue", customFieldValue);
List customFields = Collections.singletonList(customFieldMap);
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(customFields), null);
log.info("测试同步观众自定义信息结果:{}", response);
//do somethings
}