47 lines
1.7 KiB
Java
47 lines
1.7 KiB
Java
|
|
package com.zhgd.xmgl.util;
|
||
|
|
|
||
|
|
import com.alibaba.fastjson.JSONObject;
|
||
|
|
import com.zhgd.xmgl.util.imou.HttpSend;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @program: wisdomSite
|
||
|
|
* @description: 乐橙视频工具类
|
||
|
|
* @author: Mr.Peng
|
||
|
|
* @create: 2020-11-11 11:04
|
||
|
|
**/
|
||
|
|
@Slf4j
|
||
|
|
public class ImouVideoUtil {
|
||
|
|
|
||
|
|
|
||
|
|
public static String getToken(String appKey, String appSecret) {
|
||
|
|
HashMap<String, Object> paramsMap = new HashMap<String, Object>();
|
||
|
|
JSONObject json = HttpSend.execute(paramsMap, "accessToken", appKey, appSecret);
|
||
|
|
JSONObject jsonResult = json.getJSONObject("result");
|
||
|
|
JSONObject jsonData = jsonResult.getJSONObject("data");
|
||
|
|
String token = jsonData.getString("accessToken");
|
||
|
|
return token;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static String getKitToken(String token, String deviceId, String appKey, String appSecret, String channelId) {
|
||
|
|
HashMap<String, Object> paramsMap = new HashMap<String, Object>();
|
||
|
|
paramsMap.put("token", token);
|
||
|
|
paramsMap.put("deviceId", deviceId);
|
||
|
|
paramsMap.put("channelId", channelId);
|
||
|
|
paramsMap.put("type", "0");
|
||
|
|
JSONObject json = HttpSend.execute(paramsMap, "getKitToken", appKey, appSecret);
|
||
|
|
JSONObject jsonResult = json.getJSONObject("result");
|
||
|
|
JSONObject jsonData = jsonResult.getJSONObject("data");
|
||
|
|
String kitToken = jsonData.getString("kitToken");
|
||
|
|
return kitToken;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void main(String[] args) {
|
||
|
|
String token = getToken("lce64d43bce13b4f19", "aa0686f5f9fd44deacb18003345c15");
|
||
|
|
String s = getKitToken(token, "6G07ECFPAZ2B319", "lce64d43bce13b4f19", "aa0686f5f9fd44deacb18003345c15", "1");
|
||
|
|
log.info(s);
|
||
|
|
}
|
||
|
|
}
|