本文主要是介绍萤石云接口调用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
获取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);}
}
这篇关于萤石云接口调用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!