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 |
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://your-endpoint:443. You can click here to view the endpoints enabled for OBS. |
|
ssl_verify |
boolean or string |
Optional |
Whether to verify server-side certificates. Possible values are:
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. |
Sample Code
// Import the dependency library.
require 'vendor/autoload.php';
// Import the SDK code library during source code installation.
// require 'obs-autoloader.php';
// Declare the namespace.
use Obs\ObsClient;
// Create an instance of ObsClient.
$obsClient = new ObsClient([
'key' => '*** Provide your Access Key ***',
'secret' => '*** Provide your Secret Key ***',
'endpoint' => 'https://your-endpoint',
'ssl_verify' => false,
'max_retry_count' => 1,
'socket_timeout' => 20,
'connect_timeout' => 20,
'chunk_size' => 8196
]);
Last Article: Initialization
Next Article: Log Initialization
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.