pleiades-decom/php-api-client

PLEIADES API 客户端 PHP 库

dev-main 2023-03-22 12:17 UTC

This package is not auto-updated.

Last update: 2024-09-23 21:03:04 UTC


README

访问 PLEIADES API 的库。

需要 PHP 7.4 及以上版本。

基本用法示例

$api = new \PleiadesDecom\PhpApiClient\Client([
  "clientId" => "", // your app's client ID
  "clientSecret" => "", // your app's client secret
  "userName" => "", // name of the user to authenticate
  "userPassword" => "", // password of the user to authenticate
  "iamTokenEndpoint" => "", // OIDC endpoint address of IAM server
  "apiEndpoint" => "", // API server endpoint address
]);
$api->getAccessToken();
$api->setDatabase("testDatabase");
$records = $api->getRecords(["class" => "Database.Information"]);

处理记录

创建记录

$createdRecordId = $api->createRecord([
  "class" => "Any.Valid.Class.Name",
  "content" => ["AnyValidContent" => "AnyValidValue"]
]);

更新记录

$api->updateRecord(
  $recordId,
  [
    "class" => "Any.Valid.Class.Name",
    "content" => ["AnyValidContent" => "AnyValidValue"]
  ]
);

删除记录

$api->deleteRecord($recordId);

获取单个记录

$record = $api->getRecord($recordId);

获取记录列表

$records = $api->getRecords(["class" => "Any.Valid.Class.Name"]);