NxFilter Tutorial
Tutorial Index

Remote API through HTTP
You may want to create operators from your own site while updating NxCloud automatically. You can build your own API set for dealing with your operators remotely using DAO and DATA classes of NxCloud.

For more information about DAO and DATA classes, read DAO and Data classes

Example API set
We have an example API set in /nxfilter/webapps/example/noacl,remoteapi.jsp. You can call this JSP page remotely through HTTP protocol. In the JSP page, there are these functions are defined,

- createOperator(opname, optype)
You can create an operator with this function. 'opname' is an operator name. For 'optype', set 1 for an business type operator and set 2 for an home type operator. On success, it returns '/OK' and on error, it returns '/ERR'.

		ex) http://localhost/example/noacl,remoteapi.jsp?action=createOperator&opname=testname&optype=1

- selectOperator(opname)
You can fetch an operator's information with this function. 'opname' is an operator name. On success, it returns a JSON array contaning the information of the operator. On error, it returns '/ERR'.

		ex) http://localhost/example/noacl,remoteapi.jsp?action=selectOperator&opname=testname

- setExpDate(opname, expDate)
This is for setting an expiration date for an operator. 'opname' is an operator name. 'expDate' is an 'yyyyMMdd' format string for the expiration date you want to set for filtering service. On success, it returns '/OK' and on error, it returns '/ERR'.

		ex) http://localhost/example/noacl,remoteapi.jsp?action=setExpDate&opname=testname&expDate=20191231

At default, the example JSP page only accepts the calls from or localhost. You have to modify the restriction part of the JPS page to accept the requests from other hosts.

		// Only localhost access allowed.

To make these remote API funtions, we only used NxFilter DAO and DATA classes. So it's possible for you to build even more complicated ones.

You can copy the example page somewhere and build your own but the filename should be started with 'noacl,' prefix for bypassing your IP based ACL in 'Config > Allowed IP'.