PHP code example of open-southeners / carbone-sdk

1. Go to this page and download the library: Download open-southeners/carbone-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/ */

    

open-southeners / carbone-sdk example snippets




return [

    // rest of services.php items here...

    'carbone' => [
        'key' => env('CARBONE_API_KEY', ''),
        'version' => '4',
    ],

];

$response = app('carbone')->template()->base64Upload($templateBase64);

if ($response->failed()) {
    throw new \Exception('Template upload failed!');
}

// This is extracted from official Carbone SDK: https://carbone.io/api-reference.html#upload-a-template-carbone-cloud-sdk-php
$templateId = $response->getTemplateId();

$carbone = new Carbone('your-carbone-api-key');

// Use this if you want to use a different API version: https://carbone.io/api-reference.html#api-version
// $carbone = new Carbone('your-carbone-api-key', '4');

$templateBase64 = base64_encode(file_get_contents('path_to_your_template_here'));

$response = $carbone->template()->base64Upload($templateBase64);

if ($response->failed()) {
    throw new \Exception('Template upload failed!');
}

// This is extracted from official Carbone SDK: https://carbone.io/api-reference.html#upload-a-template-carbone-cloud-sdk-php
$templateId = $response->getTemplateId();