PHP code example of shipstream / spscommerce-php-sdk
1. Go to this page and download the library: Download shipstream/spscommerce-php-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/ */
shipstream / spscommerce-php-sdk example snippets
ShipStream\SpsCommerce\HttpClient\DefaultApi
use ShipStream\SpsCommerce\HttpClient\TransactionApi;
use ShipStream\SpsCommerce\HttpClient\ValidationError;
use ShipStream\SpsCommerce\HttpClient\InternalServerError;
use InvalidArgumentException;
$client = new DefaultApi(fn() => "MYACCESSTOKEN");
$api = new TransactionApi($client);
try {
$file_path = "in/CA584618-1-v7.7-BulkImport.json";
$file_content = file_get_contents($file_path);
$header = [
'Content-Type' => 'application/octet-stream',
'sps-meta-description' => 'Creating new Transaction at specified path',
];
$result = $api->createTransaction($file_path, $header, $file_content);
print_r($result)
} catch (InvalidArgumentException $e) {
echo $e->getMessage();
} catch (ApiException $e) {
echo $e->getMessage();
} catch (ValidationError $e) {
echo $e->getMessage();
} catch (InternalServerError $e) {
echo $e->getMessage();
}