PHP code example of danmichaelo / ncip

1. Go to this page and download the library: Download danmichaelo/ncip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

danmichaelo / ncip example snippets



use Scriptotek\Ncip\NcipConnector,
    Scriptotek\Ncip\NcipClient;

$ncipUrl = 'http://eksempel.com/NCIPResponder';
$userAgent = 'My NCIP client/0.1';
$agencyId = 'a';

$conn = new NcipConnector($ncipUrl, $userAgent, $agencyId);
$client = new NcipClient($conn);


use Scriptotek\Ncip\NcipServer;

$server = new NcipServer;

$client = App::make('ncip.client');
$server = App::make('ncip.server');

// Or if you have access to an instance of the application.
$client = $app['ncip.client'];
$server = $app['ncip.server'];

$user = $client->lookupUser('abc123');
if ($user->exists) {
	echo 'Hello ' . $user->firstName . ' ' . $user->lastName;
} else {
	echo 'User not found';
}

$postData = file_get_contents('php://input');
$request = $server->parseRequest($postData);

if ($request->is('LookupUser')) {

	$response = new UserResponse;
	$response->userId = $request->userId;
	$response->firstName = 'Meriadoc';
	$response->lastName = 'Brandybuck';
	echo $response->xml();

}

$client->on('request.checkout', function($userId, $itemId) {
	$log->addInfo('Requested checkout of item "' . $itemId . '" for user "' . $userId . '"');
}

$client->on('message.send', function($msg) {
	printf("[SEND] %s\n", $msg);
}
$client->on('message.recv', function($msg) {
	printf("[RECV] %s\n", $msg);
}