PHP code example of rbech / economic-api

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

    

rbech / economic-api example snippets


use \RBech\Economic\Economic;

$economic = new Economic('your-app-secret', 'your-grant-token');

$customers = $economic->get('customers');

print_r($customers);

$result = $economic->post('customers', [
    'address' => 'My fancy address',
    'city' => 'Fancyville',
    'zip' => '9999',
    'customernumber' => 900000000,
    'email' => '[email protected]',
    'name' => 'John Doe',
    'telephoneAndFaxNumber' => '11223344',
    'currency' => 'DKK',
    'customerGroup' => [
        'customerGroupNumber' => 1,
    ],
    'vatZone' => [
        'vatZoneNumber' => 1,
    ],
    'paymentTerms' => [
        'paymentTermsNumber' => 1
    ]
]);

if ($economic->success()) {
    print_r($result);
} else {
    //getLastError will return a simple string
    echo $economic->getLastError();
    
    //getErrors returns an array of errors returned
    print_r($economic->getErrors());
}