• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (PHP SDK)
  4. Initialization
  5. ObsClient Initialization

ObsClient Initialization

API Description

ObsClient functions as the PHP client for accessing OBS. It offers callers a series of APIs for interaction with OBS. These APIs are used for managing and operating resources, such as buckets and objects, stored in OBS.

Namespace

Class

Parent Namespace

ObsClient

Obs\S3

Method Definition

1. Constructor form: ObsClient(array $parameter)
2. Factory form: ObsClient::factory(array $parameter)

Parameter Description

Field

Type

Optional or Mandatory

Description

key

string

Mandatory

AK

secret

string

Mandatory

SK

endpoint

string

Mandatory

Endpoint for accessing OBS, which contains the protocol type, domain name (or IP address), and port number. For example, https://yourdomainname:443.

ssl_verify

boolean

or

string

Optional

Whether to verify server-side certificates. Possible values are:

  • Path to the server-side root certificate file in .pem format
  • false: The server-side certificates will not be verified.

The default value is false.

max_retry_count

integer

Optional

Maximum number of retries when an HTTP/HTTPS connection is abnormal. The default value is 3.

socket_timeout

integer

Optional

Timeout duration for transmitting data at the socket layer, in seconds. The default value is 60.

connect_timeout

integer

Optional

Timeout period for establishing an HTTP/HTTPS connection, in seconds. The default value is 60.

chunk_size

integer

Optional

Block size for reading socket streams, in bytes. The default value is 65536.

ssl.certificate_authority

boolean

or

string

Optional

This is a deprecated parameter and is used for compatibility with earlier versions. If ssl_verify is set, this parameter is ineffective.

Whether to verify server-side certificates. Possible values are:

  • Path to the server-side root certificate file in .pem format
  • false: The server-side certificates will not be verified.

The default value is false.

Sample Code

// Import the third-party open source library.
require 'vendor/autoload.php';
// Import the SDK code library.
require 'obs-autoloader.php';
// Declare the namespace.
use Obs\S3\ObsClient;

// Create an instance of ObsClient.
$obsClient = new ObsClient([
      'key' => '*** Provide your Access Key ***',
      'secret' => '*** Provide your Secret Key ***',
      'endpoint' => 'https://yourdomainname',
      'ssl_verify' => false,
      'max_retry_count' => 1,
      'socket_timeout' => 20,
      'connect_timeout' => 20,
      'chunk_size' => 8196
]);