PHP code example of trevweb / cin7-core-api-v2-client

1. Go to this page and download the library: Download trevweb/cin7-core-api-v2-client 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/ */

    

trevweb / cin7-core-api-v2-client example snippets


$accountId = 'your_account_id';
$applicationKey = 'your_application_key';
$client = new Cin7CoreApiV2Client($accountId, $applicationKey);

try {
    $product = $client->get(Cin7CoreEndpoints::PRODUCT, ['Name' => 'Big Tyre']);
    print_r($product);
} catch (Exception $e) {
    // Handle exception
    echo "Error fetching product: " . $e->getMessage();
}

try {
    $saleData = [
            "CustomerID" => "guid-of-customer",
            "TaxRule" => "Tax on Sales",
            "Location" => "Main Warehouse",
            // ... other Message();
}

try {
    $products = $client->fetchAll(Cin7CoreEndpoints::PRODUCT, 'Products');
    foreach ($products as $product) {
        print_r($product);
    }
} catch (Exception $e) {
    echo "Error fetching products: " . $e->getMessage();
}


DEFINE('CIN7_ACCOUNT_ID', 'your-id-here');
DEFINE('CIN7_APPLICATION_KEY', 'your-key-here');