alibabacloud / dkms-gcs-sdk
Aliyun Dkms Gcs SDK Library for PHP
Installs: 2 223
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 3
Open Issues: 1
Requires
- php: >=5.6
- ext-json: *
- ext-openssl: *
- alibabacloud/darabonba-array: ^0.1.0
- alibabacloud/darabonba-encode-util: ^0.0.2
- alibabacloud/darabonba-map: ^0.0.1
- alibabacloud/darabonba-signature-util: ^0.0.4
- alibabacloud/darabonba-stream: ^0.0.1
- alibabacloud/darabonba-string: ^0.1.14
- alibabacloud/openapi-util: ^0.1.10|^0.2.1
- alibabacloud/tea: ^3.2.1
- alibabacloud/tea-utils: ^0.2.18
- google/protobuf: ^3.3
README
English | 简体中文
AlibabaCloud DKMS-GCS SDK for PHP
Requirements
- PHP 5.6 or later
Installation
As a dependency via Composer(recommended)
Run the following in the base directory of your project to install AlibabaCloud DKMS SDK for PHP as a dependency:
composer require alibabacloud/dkms-gcs-sdk
Or, You can also declare the dependency on AlibabaCloud DKMS SDK for PHP in the composer.json file:
"require": {
"alibabacloud/dkms-gcs-sdk": "^0.4.0"
}
Then run the following to install the dependency:
composer install
After the Composer Dependency Manager is installed, import the dependency in your PHP code:
require_once __DIR__ . '/vendor/autoload.php';
Download SDK source code directly
Download the SDK source code, and introduce the autoload.php file under the SDK directory to your code:
require_once '/path/to/dkms-gcs-sdk/autoload.php';
Quick Examples
<?php
require __DIR__ . '/vendor/autoload.php';
use AlibabaCloud\Dkms\Gcs\OpenApi\Util\Models\RuntimeOptions;
use AlibabaCloud\Dkms\Gcs\Sdk\Client as AlibabaCloudDkmsGcsSdkClient;
use AlibabaCloud\Dkms\Gcs\OpenApi\Models\Config as AlibabaCloudDkmsGcsOpenApiConfig;
use AlibabaCloud\Dkms\Gcs\Sdk\Models\AdvanceEncryptRequest;
use AlibabaCloud\Tea\Utils\Utils as AlibabaCloudTeaUtils;
// 1.Create DKMS SDK client config
$config = new AlibabaCloudDkmsGcsOpenApiConfig();
$config->protocol = 'https';
$config->clientKeyContent = '<your client key content>';
$config->password = '<your client key password>';
$config->endpoint = '<your dkms instance service address>';
// 2.Create DKMS SDK client instance
$client = new AlibabaCloudDkmsGcsSdkClient($config);
// 3.Create and set up parameters RuntimeOptions instance
$runtimeOptions = new RuntimeOptions();
// set CA certificate
//$runtimeOptions->verify = 'path/to/caCert.pem';
// or, ignore certificate
$runtimeOptions->ignoreSSL = true;
// 4.Create an API request and set parameters
$encryptRequest = new AdvanceEncryptRequest();
$encryptRequest->keyId = '<your cmk id>';
$encryptRequest->plaintext = AlibabaCloudTeaUtils::toBytes('encrypt plaintext');
// 5.Initiate the request and handle the response or exceptions
try {
$encryptResponse = $client->advanceEncryptWithOptions($encryptRequest, $runtimeOptions);
var_dump($encryptResponse->toMap());
} catch (Exception $error) {
if ($error instanceof \AlibabaCloud\Tea\Exception\TeaError) {
var_dump($error->getErrorInfo());
}
var_dump($error->getMessage());
var_dump($error->getTraceAsString());
}
License
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.