PHP code example of fbclit / opentextapi

1. Go to this page and download the library: Download fbclit/opentextapi 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/ */

    

fbclit / opentextapi example snippets




bcl\OpenTextApi\Client;

$client = new Client('https://server.com/otcs/cs.exe', 'v1');

try {
    $client->connect('username', 'secret', $ntlm = true);

    $client->api()->getNode('123456');
} catch (\Exception $ex) {
    // Could not connect / authenticate.
}



bcl\OpenTextApi\Client;

$client = new Client('http://server.com/otcs/cs.exe', 'v1');

$client->connect('username', 'secret');

$api = $client->api();

try {
    // The folder node ID of where the file will be created under.
    $parentNodeId = '12356';

    // The file name to display in OpenText
    $fileName = 'My Document.txt';

    // The actual file path of the file on the OpenText server.
    $serverFilePath = 'D:\Upload\My Document.txt';
    
    $response = $api->createNodeDocument($parentNodeId, $fileName, $serverFilePath);

    if (isset($response['id'])) {
        // The ID of the newly created document will be returned.
        echo $response['id']; 
    }   
} catch (\Exception $ex) {
    // File not found on server drive, or issue creating node from given parent.
}