PHP code example of psinfoodservice / psinfoodserviceapi

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

    

psinfoodservice / psinfoodserviceapi example snippets



PSinfoodservice\PSinfoodserviceClient;

$client = new PSinfoodserviceClient('preproduction');

// Login
$client->authentication->login('[email protected]', 'password');

// Get product
$product = $client->webApi->getProductSheet(59);
echo $product->summary->name[0]->value;

// Logout
$client->authentication->logoff();

$async = $client->async();
$async->get('brands', 'Brand/All');
$async->get('masters', 'Master/All');
$results = $async->execute();

$cached = $client->cachedMasters();
$masters = $cached->getAllMasters(); // API call
$masters = $cached->getAllMasters(); // From cache

$brands = $client->brands->getAll();
$newBrands = $client->brands->getAllByDate('-1 week');
$brandId = $client->brands->createOrUpdateBrand(['Name' => 'My Brand']);

$client->mijnPS->uploadAssortment('guid-here', '/path/to/file.xlsx');

$assets = $client->assets->getAssetsFromLogistic(12345);
$producers = $client->relations->getProducers();
$brandOwners = $client->relations->getBrandOwners();

try {
    $client->authentication->login('email', 'pass');
} catch (\PSinfoodservice\Exceptions\PSApiException $e) {
    echo $e->getMessage();
    echo $e->getTraceId(); // For debugging
}

$client = new PSinfoodserviceClient(
    environment: 'production',
    verifySSL: true,
    autoRefreshEnabled: true,
    retryConfig: [
        'enabled' => true,
        'max_retries' => 3,
        'rate_limit_auto_wait' => true,
        'logger' => $psrLogger
    ]
);