PHP code example of ecollectors / cloud-sdk

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

    

ecollectors / cloud-sdk example snippets


use Ecollectors\CloudSdk\EcollectorsCloud;

// An `ec_{env}_…` API key — the data plane (Search, Knowledge Delivery).
$client = EcollectorsCloud::withApiKey('ec_production_...');

// A Sanctum token from register()/login() — self-service account
// management (Organisations, Products, Applications, Environments, Keys).
$client = EcollectorsCloud::withUserToken($token);

$results = $client->search()->query('kgv half rupee 1912');

$variant = $client->knowledge()->variant('KGV1R-1911-CAL');

$auth = EcollectorsCloud::withApiKey('')->auth()->register([
    'name' => 'Ada Lovelace',
    'email' => '[email protected]',
    'password' => 'correct-horse-battery-staple',
]);

$client = EcollectorsCloud::withUserToken($auth->token);

$organisation = $client->organisations()->create(['name' => 'NumisPoint Ltd']);
$product = $client->products()->create($organisation->id, ['name' => 'NumisPoint']);
$application = $client->applications()->create($organisation->id, $product->id, ['name' => 'Website']);

use Ecollectors\CloudSdk\Exceptions\NotFoundException;

try {
    $client->knowledge()->variant('NO-SUCH-VARIANT');
} catch (NotFoundException $e) {
    // $e->status === 404, $e->problemCode === 'not_found'
}

EcollectorsCloud::contractVersion(); // '452ffd6ab234...'