Aigents server configuration and web API use


Aigents server configuration

The following procedure describes configuration of Aigents server operating in command-line (so called “Aigents Farm”) mode with no user interface.

  1. Download Aigents.jar file from http://aigents.com/en/products.html and copy it to binary folder, for example - /var/www/aigents/bin

  2. Disable access to binary folder to web users so its content could not be opened by web server

  3. Download Aigents web files from http://aigents.com/ui/aigents-wui.zip and unzip them to web folder, for example - /var/www/aigents/html

  4. Configure web server, so it points to index.html file in web folder, for example - aigents.mysite.org pointing to /var/www/aigents/html/index.html

  5. Edit aigents-wui.js file, changing the line

var base_url = "http://cigents.com:1180";

to your web site internet address domain and port intended to host Aigents API, for example

var base_url = "http://aigents.mysite.org:1180";

  1. Configure port intended to host Aigents API (for exampe - 1180) so it is made available for access from the internet (or intranet if you are going to access Aigents locally)

  2. Download Oracle Java Mail bundle from http://www.oracle.com/technetwork/java/javamail/index.html and copy its mail.jar file to binary folder (for current example - /var/www/aigents/bin)

  3. Start Aigents server in binary folder:

#java -cp .:Aigents.jar:mail.jar net.webstructor.agent.Farm -Xms128m -Xmx256m

  1. Setup administrative account (need to fill properties name, surname, email, birth date, secret question, secret answer) - from Aigents command line interface:

I:Started TCP at 1123.

I:Started HTTP at 1180.

my name admin

Login:name admin.

I:What your email, surname, birth date?

my email admin@mysite.org

Login:email admin@mysite.org, name admin.

I:What your surname, birth date?

my surname admini, birth date 1/1/2001

Login:birth date 1/1/2001, email admin@mysite.org, name admin, surname admini.

I:What your secret question, secret answer?

my secret question password, secret answer 12345

I:What your password?

my password 12345

...

I:Ok. Hello Admin Admini!

My Aigents 1.0.9 Copyright 2014 Anton Kolonin, Aigents Group.

  1. Setup web API for access via http protocol, filling properties http origin, http port, cookie domain, cookie name (port 1180 for our exampe) - from Aigents command line interface:

your http origin http://aigents.mysite.org, http port 1180, cookie domain aigents.mysite.org, cookie name myaigent.

...

I:Ok.

what your http origin, http port, cookie domain, cookie name?

...

I:My cookie domain aigents.mysite.org, cookie name myaigent, http origin http://aigents.mysite.org, http port 1180.

  1. Setup email account for access via email (POP3 and SMTP) and for sending notifications (SMTP), filling properties email, email login, email password, mail.pop3s.host, mail.smtp.host (for example, based on mysite.org) - from Aigents command line interface:

    your email aigent@mysite.org, email login aigent, email password qwerty, mail.pop3s.host mail.mysite.org, mail.smtp.host mysite.org.

    ...

    what your email, email login, email password, mail.pop3s.host, mail.smtp.host?

    ...

    My email aigent@mysite.org, email login aigent, email password 'qwerty', mail.pop3s.host mail.mysite.org, mail.smtp.host mysite.org.

  2. Setup TCP/IP port for telnet terminal access, filling tcp port property (for example, port 1123) - from Aigents command line interface:

your tcp port 1123

I:Ok.

what your tcp port?

...

I:My tcp port 1123.

  1. Exit Aigents server altogether with command-line interface:

    bye

...

#Connection closed by foreign host.

  1. Start Aigetns over per step 8 above, but now better using screen or nohup Linux commands so that server keeps running uninterruptedly upon current console session termination.

  2. For remote control of Aigents server from console, use the tcp/ip port specified above to connect to Aigents via telnet:

$ telnet aigents.mysite.org 1123

Trying 111.22.0.33...

Connected to aigents.mysite.org.

Escape character is '^]'.

my name admin

What your password?

my password 12345

Ok. Hello Admi Admini!

My Aigents 1.0.9 Copyright © 2014 Anton Kolonin, Aigents®.


Aigents web API use

The following describes access to Aigents server operating in command-line (so called “Aigents Farm” mode) by means of its web API over http protocol – for the purpose of Web monitoring and news collection.

  1. Authentication is based on cookies (configured with properties cookie domain and cookie name, as described above). That is, respective fields of the HTTP header should be filled.

$baseURL = "http://aigents.mysite.org:1180/?";

$cookie;

global $baseURL, $cookie;

$pest = new Pest($baseURL);

try {

$url = $baseURL.urlencode($url);

if (isset($cookie)) {

$pest->curl_opts[CURLOPT_COOKIE] = $cookie;

}

$result = $pest->get($url);

$cookie=$pest->last_headers['set-cookie'];

unset($pest);

return $result;

} catch( Exception $e ) {

unset($pest);

throw($e);

}

}

  1. Requests and response are currently processed as HTTP GET requests, so the response is submitted to URL including domain name and optional port, followed by slash and question mark with following URI-encoded text of complete statement in Agent Language, to be parsed accordingly to language defintion (http://aigents.com/papers/2014AgentLanguageKolonin.pdf) while response is written to the stream, for example – the authentication is done as shown below.

  1. Operations with sites, things and news used for web monitoring are performed accordingly to belief ontology of Aigents for Web (http://aigents.com/papers/2014AgentWatchingKolonin.pdf), as described below. All of the following operations are possible after user is authenticated (logged in).

Example:

For example, unit test for Aigents server can be downloaded from the following link:

http://aigents.com/download/api/aigents-php-demo.zip

To run the test, need to start Aigents server in one console session and then run the test in another console session:

#java -cp .:Aigents.jar:mail.jar net.webstructor.agent.Farm store path '', cookie domain localtest.com

#php -f agent_test.php



Copyright 2014 Anton Kolonin