2017 © Pedro Peláez
 

library net2web

Net2Web Client Library

image

gyron/net2web

Net2Web Client Library

  • Friday, January 5, 2018
  • by dlgoodchild
  • Repository
  • 3 Watchers
  • 1 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

net2web

PHP client library for Net2Web., (*1)

About

Net2, by Paxton, is an access control systems developer and provider. Their software runs on Windows and does have an SDK (in .NET), however it does not have a remotely accessible API of any sort. Net2Web runs alongside Net2 and exposes ~90% of the SDK functionality as an XML web accessible API., (*2)

This library aims to simply integration with the Net2Web exposed API., (*3)

Installation Instructions

Composer

Via command line simply do:, (*4)

composer require gyron/net2web

Alternatively you can update the "require": { section in your composer.json with a line reading:, (*5)

"gyron/net2web" : "v1.0.2"

Usage

Quick Start

Simply copy and paste the following code, and adjust the values:, (*6)

$oNet2Encryption = new \Gyron\Net2Web\Encryption( 'ENCRYPTION KEY', \Gyron\Net2Web\Encryption::OpenSSL );
$oNet2Session = new \Gyron\Net2Web\Session( 'USERID', 'PASSWORD', 'NET2 SERVER IP', '7070', $oNet2Encryption );
$oNet2Client = new \Gyron\Net2Web\Client( $oNet2Session );

This will get you connected immediately, however it will create a new Net2Web session for every request.
It is recommended that you use $oNet2Session->getSessionId(), and cache this somewhere (for up to 2 to 4 hours). This can then be reused by passing the Session ID back into the Session instance:
new Session( ..., ..., ..., ..., $oEncryption $sessionId );, (*7)

Advanced Implementation

Following is a sample implementation of the library in the form of a service factory which utilises caching of the session ID to local storage., (*8)

<?php declare( strict_types=1 );

namespace Gyron\Sample;

use Gyron\Net2Web\Client;
use Gyron\Net2Web\Encryption;
use Gyron\Net2Web\Session;

/**
 * Class AccessApiFactory
 * @package Gyron\Sample
 */
class AccessApiFactory {

  /**
   * @var string
   */
  private $sCachePath;

  /**
   * @param string $sCachePath
   */
  public function __construct( string $sCachePath ) {
    $this->sCachePath = $sCachePath;
  }

  /**
   * @param array $aConfig requires user_id, password, ip and port
   * @return Client
   * @throws \Exception
   */
  public function forConfig( array $aConfig ) {
    $sCacheFile = sprintf( '%s/net2web_session.sid', rtrim( $this->sCachePath, '/' ) );

    $sSessionId = null;
    if ( is_file( $sCacheFile ) ) {
      $sSessionId = trim( file_get_contents( $sCacheFile ) );
    }

    $oNet2Encryption = new Encryption( $aConfig['enckey']', Encryption::OpenSSL );
    $oNet2Session = new Session( $aConfig['user'], $aConfig['password'], $aConfig['host'], (string)$aConfig['port'], $oNet2Encryption, $sSessionId );
    if ( $sSessionId != $oNet2Session->getSessionId() ) {
      file_put_contents( $sCacheFile, trim( $oNet2Session->getSessionId() ) );
    }
    return ( new Client( $oNet2Session ) );
  }
}

The Versions

05/01 2018

dev-master

9999999-dev http://www.gyron.net

Net2Web Client Library

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dave Goodchild

api php api-client net2web paxton net2

05/01 2018

v1.0.2

1.0.2.0 http://www.gyron.net

Net2Web Client Library

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dave Goodchild

api php api-client net2web paxton net2

25/08 2017

v1.0.1

1.0.1.0 http://www.gyron.net

Net2Web Client Library

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dave Goodchild

api php api-client net2web paxton net2

25/08 2017

v1.0

1.0.0.0 http://www.gyron.net

Net2Web Client Library

  Sources   Download

MIT

The Requires

 

by Dave Goodchild

api php api-client net2web paxton net2

28/07 2017

v1.0-beta

1.0.0.0-beta http://www.gyron.net

Net2Web Client Library

  Sources   Download

MIT

The Requires

  • php >=7.1

 

by Dave Goodchild

api php api-client net2web paxton net2