fbclit/opentextapi

PHP OpenText API 客户端。

v0.0.4 2020-07-29 18:36 UTC

This package is auto-updated.

Last update: 2024-09-13 03:56:29 UTC


README

Build Status

PHP OpenText API 客户端。

要求

  • PHP >= 7.1
  • ext-json

您还必须在管理员配置中启用 REST API。

通常位于

https://myserver.com/otcs/cs.exe?func=enterprisearchivesp.restapiconfig

启用 REST API(默认): [x]

安装

composer require fbclit/opentextapi

用法

<?php

require_once('vendor/autoload.php');

use Fbcl\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.
}

上传文件

OpenText 不支持通过 POST 请求常规上传文件。它只支持通过异步 JavaScript 请求的流式文件上传。

要执行文件上传,您 必须 将文件放置在您的 OpenText 配置的 Web 服务器上的 Uploads 目录中。此目录在管理员 Web 界面中配置,位置为

https://server.com/otcs/cs.exe?func=admin.sysvars

上传目录 输入添加到内容服务器的临时存储目录的规范(可选)。如果指定,内容服务器将只添加此目录中找到的上传文件。

通常设置为 D:\Upload 文件夹。

<?php

require_once('vendor/autoload.php');

use Fbcl\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.
}