1. Go to this page and download the library: Download chainberry/external-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chainberry / external-sdk-php example snippets
$config = [
'environment' => 'staging', // or 'production', 'local'
'apiVersion' => 'v2', // or 'v1' (defaults to 'v1' if not set)
'clientId' => 'your_client_id',
'clientSecret' => 'your_client_secret',
'privateKey' => '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----'
];
penAPI\Client\BerrySdk;
// Initialize with environment variables
BerrySdk::init();
// Or initialize with configuration array
BerrySdk::init($config);
use OpenAPI\Client\Utils\Validators;
use OpenAPI\Client\Utils\ValidationRules;
// Use pre-built validators
$emailValidator = Validators::email();
$result = $emailValidator->validate('[email protected]');
if (!$result->isValid) {
echo "Validation errors: " . implode(', ', $result->errors);
}
// Create custom validator
$customValidator = new Validator();
$customValidator
->addRule(ValidationRules::
use OpenAPI\Client\Utils\Retry;
use OpenAPI\Client\Utils\RetryOptions;
// Use retry with default options
$result = Retry::withRetry(function() {
// Your operation here
return someApiCall();
});
// Use retry with custom options
$options = new RetryOptions([
'maxAttempts' => 5,
'baseDelay' => 2000,
'maxDelay' => 30000,
'backoffMultiplier' => 1.5
]);
$result = Retry::withRetry(function() {
return someApiCall();
}, $options);
use OpenAPI\Client\BerrySdk;
use OpenAPI\Client\Utils\Logger;
use OpenAPI\Client\Utils\LogLevel;
// Get logger instance
$logger = BerrySdk::getLogger();
// Configure logger
$logger->setLevel(LogLevel::DEBUG);
$logger->setPrefix('[MyApp]');
// Log messages
$logger->info('Application started');
$logger->debug('Debug information', ['data' => $someData]);
$logger->warn('Warning message');
$logger->error('Error occurred', ['error' => $error]);
apiInstance = new OpenAPI\Client\Api\AssetApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
try {
$result = $apiInstance->assetV2ControllerGetSupportedAssetsV2();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AssetApi->assetV2ControllerGetSupportedAssetsV2: ', $e->getMessage(), PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.