PHP code example of techkat / backblaze-b2-php-sdk
1. Go to this page and download the library: Download techkat/backblaze-b2-php-sdk 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/ */
techkat / backblaze-b2-php-sdk example snippets
use TechKat\BackBlazeB2\Client;
$keyID = '<insert the key ID here>';
$applicationKey = '<insert the application key here>';
$options = array(
// Time in seconds on how long a BackBlaze B2 authorization token should remain in cache.
'authTimeout' => 43200,
// Which version of the BackBlaze B2 API you should use. It is best to keep as 2.
'version' => 2,
// If the BackBlaze B2 authorization token needs to be recycled on runtime, set this to true.
// Keep in mind that keeping this option to true always will incur additional class C transactions on BackBlaze B2's API.
'forceReauthorization' => false,
);
$client = new Client($keyID, $applicationKey, $options);
// This returns a list of Bucket models per BackBlaze B2 bucket that the key ID and application key has access to.
$buckets = $client->listBuckets();
foreach($buckets as $bucket)
{
echo 'Bucket Name: ' . $bucket->getName();
}