Controls CGI
Version / Author / Date | Modify |
---|---|
1.0/David/2013-03-30 | First edition |
ReeCam IP Camera CGI interface is provided to the user to use a set of HTTP CGI-based application development interface. The user can use this interface:
CGI Call
Call the CGI interface directly in the browser and player, for example:
location = 'set_params.cgi? alias = ipcam-demo'; - <Implemented in a computer programming language.
User Authentication
User invokes the CGI interface IP Camera, IP Camera username/password authentication must be carried out to the user to determine whether it can meet the user's permissions. Permissions required by each CGI command, by definition, have the permissions on the IP Camera is divided into two categories: managers and visitors. Managers have all the permissions function; while the visitors were awarded according to the set combination of the following privileges: 1 video access: access to the video. 2 pictures permissions: You can take pictures of operation. 3 video permissions: remote video operation, ie video IP Camera SD card IP Camera set network shared directory. 4 audio access: listening. Dialogue permission: dialogue with the IP Camera. 6 control permissions: IP Camera PTZ control and camera parameters can be performed.
CGI interface to support user authentication, there are three: 1 certification based on the way the HTTP Basic Authentication. For example, in the browser address bar directly input http://192.168.0.188/get_params.cgi, the browser prompt username/password authentication window will pop up to alert the user, If the program is written in a programming language, you can increase the Authentication field in the HTTP request sent to the IP Camera to implement user authentication. Based on the parameters in the form of certification. Example, directly in the browser address bar enter http://192.168.0.188/get_params.cgi?user=admin&pwd = HTTP request additional user and pwd parameters to achieve the user authentication. Session-based authentication. Created before a Session, directly in the HTTP request additional session parameters to achieve user authentication. For example, you can be entered directly in the browser address bar http://192.168.0.188/get_params.cgi?session=20983424, IP Camera No. 20,983,424 of the session will be created prior to grant the user rights of the Session Current users visit. These three authentication methods, if used, the third highest priority, the first priority of the lowest.
CGI Returns
CGI interface to return to the four types of data: 1 text message 2.js text messages 3.json/jsonp text messages 4 files CGI interface can be divided into three categories according to the return type: A class of CGI, the user will need to get a file or a series of streaming data. For example snapshot.cgi, backup.cgi, av.asf ... such as cgi such as the operation fails, then return to the failed text messages, and if successful, returns the corresponding file. A class operation and settings like CGI, such CGI users only care about the results of the operation and settings. For example set_params.cgi, ptz_control.cgi ... json/jsonp type of data a kind of cgi settings when the call returns json/jsonp data, whether successful or not, are returned to indicate the result of the operation, such as: {"Error": -2} json data callback ({"error": 0}); jsonp data b. json/jsonp data is returned, the operation is not set called failure will certainly return to the text message, for example, Operation failed: invalid ip and mask. Representing the operation to fail, given the failure of the reasons is invalid ip and mask parameters Operation failed: invalid user settings. Representatives operation failed, and given the failure due to invalid user parameter While operation was successful based on whether the user when invoked set next_url parameters, if not set, returns the success of text information, for example: Operation Succeed. Representative of the operation is successful Otherwise, camera will return specified page next_url. For example: http://192.168.0.188/set_params.cgi?...&next_url=user.htm If the operation is successful, IP Camera will return page of user.htm, Of course, if the operation failed, or will return to operation fails and causes the text information. Note: The specified page must next_url IP Camera on the page and not the page on other sites. the page specified next_url nor incidental parameters. A class CGI query classes CGI for such CGI, you not only need to know whether the operation was successful, and also need to know the specific value. For example: get_status.cgi, get_params.cgi json/jsonp type of data a kind of cgi settings when the call returns json/jsonp data, whether successful or not, are returned to indicate the result of the operation, such as: {"Error": 0, "time": 1363592625, "alarm": 0, "upnp": 0, "ntp": 1, "record": 0, "disk": 0, "ddns": 0, " skype ": 0," tutk ": 0} json data callback ({"error": -2}); jsonp data b such cgi called set the returned json/jsonp data returns if the operation fails friendly text information, but if the operation is successful, it will return js text messages. For example, the user wants to query the IP address of the IP Camera: http://192.168.0.188/get_params.cgi?ip = IP Camera will return: var ip = '192 .168.0.188 '; Some CGI returns may also be javascript array variable form. For example: http://192.168.0.188:8080/get_session_list.cgi IP Camera will return: var session_user = new Array (); var session_ip = new Array (); session_user [0] = 'admin'; session_ip [0] = '192 .168.0.16 '; var number = 1; Of which session_user and session_ip are an array of variables, and the number is the number of members of the array. For some applications, the user may not want to use the name of the variables returned by the default IP Camera Such as the first example, the user does not want to use the ip variable name, but the variable name want to use camera_ip, you can: http://192.168.0.188/get_params.cgi?ip=camera_ip IP Camera will return: var camera_ip = '192 .168.0.188 ';
How do I set cgi return json/jsonp type of data? The cgi parameters increase json parameter and jsonp_callback parameter which the json parameter specifies the type of data returned by the camera:
Camera returned json object, there will always be an error variable to specify the cgi call:
0 |
operation is successful |
-1 |
Operation failed: Authentication error |
-2 |
Operation failed: parameter error |
-3 |
Operation failed to achieve the maximum number of session |
-4 |
Operation failed: camera internal error |
-5 |
Operation failed: Timeout |
-6 |
Operation failed: error or is not supported by the operating request |
When the error is not equal to 0, there is no follow returns.