Examples

The examples described below are just a fraction of those contained in this documentation, and examples in different languages can also be found in our GitHub repository: https://github.com/controlid/integracao/tree/master/Controle%20de%20Acesso

Collect logs

The method load_objects is used to collect information from the device. In this example, it was used to collect the access logs that were stored on the device.

Example C#

For the development of this example, the library RestSharp is being used.

public string GetAccessLogs()
{
  var client = new RestClient("http://192.168.2.183/load_objects.fcgi");
  var request = new RestRequest(Method.POST);
  request.AddHeader("cookie", "session=o7JRuZQckN10lz66MHfX69iY");
  request.AddHeader("content-type", "application/json");
  request.AddParameter("application/json", "{\n  \"object\":\"access_logs\"\n}", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  return response.Content;
}

Example NodeJS

For the development of this example, the module Request is being used.

var request = require("request");
var options = { 
method: 'POST',
url: 'http://192.168.2.183/load_objects.fcgi',
headers: 
{ 
  cookie: 'session=QnnlmLcEBCE06mwKkh/7SOEM',
  'content-type': 'application/json' 
},
body: 
{ 
  object: 'access_logs'
},
json: true 
};
request(options, function (error, response, body) {
  if (error) throw new Error(error);
      console.log(body);
});

Activate relay

The method execute_actions is responsible for executing commands on the device, in this example, it was used to open the door by releasing relay 1. The example below is not applicable for iDFlex, iDBlock, iDAccess Pro, and iDAccess Nano because, for these products, the parameters are different.

Example C#

For the development of this example, the library RestSharp is being used.

public string ExecuteAction()
{
  var client = new RestClient("http://192.168.2.183/execute_actions.fcgi?session=zm3WJhwbFawo1wX9B4YRnLY4");
  var request = new RestRequest(Method.POST);
  request.AddHeader("content-type", "application/json");
  request.AddParameter("application/json", "{\n\t\n\t\"actions\": [ { \"action\": \"door\", \"parameters\": \"door=1\" } ]\n\t\n}", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  return response.Content;
}

Example NodeJS

For the development of this example, the module request is being used.

var request = require("request");
var options = { 
method: 'POST',
url: 'http://192.168.2.183/execute_actions',
headers: 
{ 
  cookie: 'session=QnnlmLcEBCE06mwKkh/7SOEM',
  'content-type': 'application/json'
},
body: 
{
  "actions": [ { "action": "door", "parameters": "door=1" } ]
},
json: true
};
request(options, function (error, response, body) {
  if (error) throw new Error(error);
    console.log(body);
});