EasyNVR RTSP turn RTMP-HLS-FLV streaming media server front-end interface to build it _ about some of the common questions (401 Unauthorized) call

Creative Commons License Creative Commons

background analysis

EasyNVR recent use of the process, many small consulting partners on the issue of interface calls, the initial judgment should be experiencing a permissions problem (401 Unauthorized) . EasyNVR provides a standard API interface for third-party systems and applications, to facilitate docking second development is exclusively their own business Internet broadcast platform. Interface definitions are generally divided into an interface and the interface caller may define a predetermined parameter and return type of the received form, and the interface is defined only by full access according to predetermined parameters by the interface definition. We are talking about is called webService (network service).

Error Status

This post will be explained based on the problem of the interface calls itself a call to EasyNVR interface and some feedback of users:

Interface Overview

API style using Restful Http protocol, all requests use Get / Post embodiment, are case-insensitive. The basic structure is as follows:

http://<IP>:<Port>/api/<Version>/<Action>?<Param1>=<value>&<Param2>=<Value>&.....

parameter

parameter name definition Explanation
IP Platform Address IP addresses
Port Platform Port Communication Port
Version API Version API version
Action Action Operations performed
Param Action Parameter Operation parameters used, there may be a plurality of parameters, each corresponding to a Value.
Value Parameter Value Parameter values, if the special characters such as & appear in a string Value, it must be "" Value wrap.

return value

API call will return Json string representing the results of the operation to return

{
   "EasyDarwin" : {
      "Body" : {
         ……
      },
      "Header" : {
         "CSeq" : "1",
         "ErrorNum" : "200",
         "ErrorString" : "Success OK",
         "MessageType" : "MSG_SC_API_ACK",
         "Version" : "1.0"
      }
   }
}

Call interface

Many small partners to focus only on functional interface, often direct mass participation tune the interface, so it was an error opening the 401; the easiest way is, after we get the interface documentation, you can read the document, be aware of;

First performed before calling the interface simple explanation: EasyNVR Most call interface information required to carry token in a cookie; for this token information, login through the interface is returned. When we successfully request Interface: When "? / Api / v1 / login username = xxx & password = xxx", returns a token information;

	{
	   "EasyDarwin" : {
	      "Body" : {
	         "Token" : "a19cb5f6e7d2449d8d24c8a0fc554ca7"
	      },
	      "Header" : {
	         "CSeq" : "1",
	         "ErrorNum" : "200",
	         "ErrorString" : "Success OK",
	         "MessageType" : "MSG_SC_SERVER_LOGIN_ACK",
	         "Version" : "1.0"
	      }
	   }
	}

We get a cookie on the token to store information. 401 appeared, in most cases is a cookie tooken carry, error interface format, send the wrong parameters.

Tips: Some big brother when requesting login interfaces found 401 rights restrictions appear; the interface through the MD5 password is encrypted. In the cookie request headers carries corresponding tooken other interfaces requests during a request.

Examples are shown below:

First introduced jqueryCookie, used to set the cookie (if there are other ways to set cookie can not quote)
	<script src="/adminlte-2.3.6/plugins/cookie/jquery.cookie.min.js"></script>
Request to the interface card via ajax
  • In the absence of call interface settings

cookie value

$.ajax({
                    type: "GET",
                    url: "api/v1/login",
                    data: {
                        username: username,
                        password: password
                    },
                    global: false,
                    success: function(data) {
                        try {
                            var ret = JSON.parse(data);
                            var token = ret.EasyDarwin.Body.Token;
                            $.cookie("token", token);
                            //将tooken设置进cookie中
                            $.cookie("username", username);
                        } catch (e) {
                            console.log(e);
                        }
                    },

After successfully processing a request via ajax the obtained data, a cookie will tooken out:

  • Call Interface and cookie settings:

EasyNVR- successfully set cookie

At this time when we request other interfaces, you will find there is cookie tooken in the request header, and can be successfully request interface.

Successful requests renderings

EasyNVR hardware

EasyNVR intelligent cloud terminal hardware equipment, to fill the gaps in the industry live Internet equipment, software and hardware integration, operation and maintenance of the clouds. Small size, easy to place deployment; 7 * 24-hour operation, low power consumption; eliminating the high cost of self-built video server; exclusive video services, from the interaction with other hardware, power network can be run successfully, deployment easy to use.
EasyNVR hardware

EasyNVR scenarios

EasyNVR can be said to have become the vanguard of the domestic Internet video infrastructure, livelihood of the people in almost every industry have already had the ability to output video EasyNVR figure, EasyNVR years of service in all walks of life video infrastructure, EasyNVR reliability, integrity, stability It has been widely recognized in the industry!
EasyNVR

Landscape Live

通过将景区的摄像头通过EasyNVR系统可以使管理部门建设掌上视频监管系统(景区内部使用)方便随时随地查各个景区的情况。同时可以将景区的经典风景通过微信、微博、网站和APP等方式对公众展示,用于宣传景区风景,展示景区魅力,提高景区知名度。
EasyNVR a scene

雪亮工程

目前各地市社会视频资源存在种类繁多,各系统独立运行,没有有效整合和联网应用,通过EasyNVR系统,将各类视频资源整合,统一管理、统一调度,资源共享,实现了资源利用最大化,避免了重复建设。

EasyNVR Scene II

平安校园

把传统分散的校园监控汇总到EasyNVR系统,实现把传统的本地监控提升到随时随地的远程监控,把传统的纯粹的监控上升到管理,使视频监控成为学校教学管理的有力工具。更重要的是让家长一起参与,提升教学的主动性。提升学校声誉和学校品牌。

Scene Three EasyNVR

平安工地

将工地的摄像头通过平台对施工方、监理方和监管部门开放,方便实时了解工程进度,工地人员安全以及财产情况,自成力能平台,专为工地构建的视频监控平台。

EasyNVR Scene Four

明厨亮灶

而随着互联网和移动互联网被广大消费者接受,“社会共治”将是是明厨亮灶目前的核心理念。采用社会共治方式,将各餐饮企业的后厨视频通过EasyNVR系统让老百姓通过手机可实时看到后厨的情况,既起到全社会监督的效果也是对餐饮企业的宣传。

EasyNVR安防摄像机网页流媒体服务

EasyNVR have is a full, independent, controllable intellectual property rights, but also can have the function of security software and hardware integration of Internet streaming media server, network camera through a simple channel configuration, monitoring industry inside traditional high-definition network camera IP Camera , etc. with the NVR RTSP, Onvif protocol output device access to EasyNVR, EasyNVR these audio and video data can be video sources is a pull, is converted to RTMP / HLS, full internet terminal H5 live (Web, Android, iOS), and EasyNVR able to broadcast live video source of data to a third party CDN network, Internet-scale distributed. EasyNVR details you may visit the official website: http://www.easynvr.com

EasyNVR intellectual property rights

Guess you like

Origin blog.csdn.net/EasyNVR/article/details/91849684