LiveNVR监控RTSP web浏览器直播中集成开发jquery调用示例

73 阅读1分钟

Onvif|RTSP流媒体服务

搭建入口,解压启动即用:www.liveqing.com/docs/downlo…

二次开发中如何调用接口

下面是完整的 jquery 调用示例

<html>
<head>
    <title>LiveNVR 接口调用示例</title>
   <script src="jquery-2.2.4.js"></script>
</head>
<body>
</body>
<script>
	 $.ajax({
        url: "http://nvr.liveqing.com:10800/api/v1/login",
        type: 'GET',
		data: {
			username:"test",
			password:"098f6bcd4621d373cade4e832627b4f6"
		},
		xhrFields: { 
			withCredentials: true
		},
		crossDomain: true, 
        success: function (ret) {
			console.log(ret)
			var token = ret.LiveQing.Body.Token;
			alert(token)
			getchannels(token)
        },
		error: function(xhr,textStatus,errorThrown){
         alert(xhr.status)
		}
	 }
	);
	
	
	<!--携带token调用其他接口示例 -->	
	function getchannels(token) {
		$.ajax({
        url: "http://nvr.liveqing.com:10800/api/v1/getchannels",
        type: 'GET',
		data: {
			start:0,
			limit:10
		},
		xhrFields: { 
			withCredentials: true
		},
		crossDomain: true, 
        beforeSend: function (xhr) {
            xhr.setRequestHeader("cookie", "token="+token);
        },
        success: function (ret) {
			console.log(ret)
			alert(JSON.stringify(ret));
        },
		error: function(xhr,textStatus,errorThrown){
         alert(xhr.status)
		}
	 }
	);
	}

</script>
</html>