PHP code example of blesta / reseller-api

1. Go to this page and download the library: Download blesta/reseller-api 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/ */

    

blesta / reseller-api example snippets


use Blesta\ResellerApi\Connection;

$connection = new Connection();
$connection->setBasicAuth($username, $password);

use Blesta\ResellerApi\Command\Credits;

$credits = new Credits($connection);

$result = $credits->get();
echo $result->response();

use Blesta\ResellerApi\Command\Packages;

$packages = new Packages($connection);

$result = $packages->get();
print_r($result->response());

$result = $packages->getPricing($package_id);
print_r($result->response());

use Blesta\ResellerApi\Command\Licenses;

$licenses = new Licenses($connection);

$data = array(
    'pricing_id' => 1,
    'test_mode' => 'true'
);
$result = $licenses->add($data);
$licenseKey = $result->response();

$data = array(
    'license' => 'abcdef0123456789',
    'reissue_status' => 'reissue',
    'test_mode' => 'true'
);
$licenses->update($data);

$data = array(
    'license' => 'abcdef0123456789',
    'test_mode' => 'true'
);
$licenses->cancel($data);

$data = array(
    'license' => 'abcdef0123456789',
    'test_mode' => 'true'
);
$licenses->suspend($data);

$data = array(
    'license' => 'abcdef0123456789',
    'test_mode' => 'true'
);
$licenses->unsuspend($data);

use Blesta\ResellerApi\Command\Search;

$search = new Search($connection);
$result = $search->data('search string')
    ->page(1)
    ->get();
print_r($result->response());

$commandFactory = new \Blesta\ResellerApi\Command\CommandFactory();
$credits = $commandFactory->create('Credits', $connection);
$packages = $commandFactory->create('Packages', $connection);
$licenses = $commandFactory->create('Licenses', $connection);
$search = $commandFactory->create('Search', $connection);