PHP code example of dropcart / php-client

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

    

dropcart / php-client example snippets


\Dropcart\PhpClient\DropcartClient::setPublicKey('PUBLIC_KEY');
\Dropcart\PhpClient\DropcartClient::setPrivateKey('PRIVATE_KEY');

\Dropcart\PhpClient\DropcartClient::catalog();
\Dropcart\PhpClient\DropcartClient::catalog()->products();
\Dropcart\PhpClient\DropcartClient::catalog()->brands();
\Dropcart\PhpClient\DropcartClient::catalog()->categories();

->get(...$args)
->post(...$args)
->put(...$args)
->delete(...$args);

\Dropcart\PhpClient\DropcartClient::catalog()->products()->get(12332);
// Will make a GET request to:
// https://rest-api.dropcart.nl/catalog/products/12332

\Dropcart\PhpClient\DropcartClient::catalog(34)->products()->get();
// Will make a GET request to:
// https://rest-api.dropcart.nl/catalog/34/products (this will actually fail because this isn't a valid endpoint)

\Dropcart\PhpClient\DropcartClient::catalog()->products()->addParams([
	'name' => 'New Product',
	'description' => 'A descriptive text about this new and awesome product. You need to buy this, yo!'
])->post();

try {
	$response   = \Dropcart\PhpClient\DropcartClient::catalog(34)->products()->get();
} catch(DropcartClientException $e) {
	die('Client error:' . $e->getMessage());
} catch (\Exception $e)
{
	die('Server error:' . $e->getMessage());
}
	
$json       = $respons->getBody();
bash
$ composer