获取appKey和secret
登录后在开发者服务-我的应用中获取
根据appKey和secret获取accessToken
参考官方文档:文档概述 · 萤石开放平台API文档
# 获取accessToken
url_accessToken="https://open.ys7.com/api/lapp/token/get"
data = {
"appKey": "***",
"appSecret": "***",
}
response = requests.post(url=url_accessToken, data=data)
accessToken = json.loads(response.text)["data"]["accessToken"]
API调用示例
# 实时预览地址
url_address="https://open.ys7.com/api/lapp/v2/live/address/get"
data ={
"accessToken": accessToken,
"deviceSerial": "***",
"channelNo":1,
"protocol": 3,
}
response = requests.post(url=url_address, data=data)
print("实时预览地址:")
print(json.loads(response.text)["data"]["url"])
在java中请求示例:
public class ysy_token {
public static void main(String[] args) {
String url = "https://open.ys7.com/api/lapp/token/get";
//定义发送数据
String appKey = "***";
String appSecret = "***";
//请求参数拼接JOSN字符串
String str = "appKey="+appKey+"&appSecret="+appSecret;
HttpRequest httprequest = new HttpRequest();
JSONObject result = httprequest.post(url,str);
System.out.println(result);
}
}