PHP code example of merch-one / php-api-sdk
1. Go to this page and download the library: Download merch-one/php-api-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/ */
merch-one / php-api-sdk example snippets
use MerchOne\PhpApiSdk\Http\Client;
class MyService
{
private Client $httpClient;
public function __construct()
{
$this->httpClient = new Client();
}
public function doSomething(): void
{
// authenticate client using credentials
$this->httpClient->auth(
'your-store-user',
'your-store-key'
);
// or authenticate client using base64 encoded credentials
$this->httpClient->basicAuth(
base64_encode('your-store-user:your-store-key'),
);
/* Interact with Catalog API */
/** @var \MerchOne\PhpApiSdk\Contracts\Clients\CatalogApi $catalogApi */
$catalogApi = $this->httpClient->catalog();
/* Interact with Orders API */
/** @var \MerchOne\PhpApiSdk\Contracts\Clients\OrdersApi $ordersApi */
$ordersApi = $this->httpClient->orders();
/* Interact with Shipping API */
/** @var \MerchOne\PhpApiSdk\Contracts\Clients\ShippingApi $shippingApi */
$shippingApi = $this->httpClient->shipping();
// switch API version you interact with
$this->httpClient->setVersion($version);
// get current API version
$this->httpClient->getVersion();
}
}
use MerchOne\PhpApiSdk\Util\MerchOneApi;
// get the list of all available API versions
MerchOneApi::getVersions();