PHP code example of simplesquid / vend-sdk

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

    

simplesquid / vend-sdk example snippets


$vend = Vend::getInstance();

/* Optional configuration. */
$vend->userAgent('Vend SDK')
     ->requestTimeout(2)
     ->confirmationTimeout(30);

$vend->domainPrefix($domain_prefix)
     ->personalAccessToken($access_token);

$vend->clientId($client_id)
     ->clientSecret($client_secret)
     ->redirectUri($redirect);

$vend->getAuthorisationUrl($previous_url);

/** @var \SimpleSquid\Vend\Resources\OneDotZero\Token */
$token = $vend->domainPrefix($domain_prefix)
              ->oAuthAuthorisationCode($code);

$vend->authorisationToken($token);

/** @var \SimpleSquid\Vend\Resources\OneDotZero\Token */
$token = $vend->refreshOAuthAuthorisationToken();

/**
 * List products.
 * Returns a paginated list of products.
 *
 * @param  int|null   $page_size  The maximum number of items to be returned in the response.
 * @param  int|null   $after      The lower limit for the version numbers to be \Resources\TwoDotZero\ProductCollection
 */
$products = $vend->product->get($page_size, $after, $before, $deleted);

/**
 * Get a single product.
 * Returns a single product object with a given ID.
 *
 * @param  string  $id  Valid product ID.
 *
 * @return \SimpleSquid\Vend\Resources\TwoDotZero\Product
 */
$product = $vend->product->find($id);