Skip to content

Instantly share code, notes, and snippets.

@unifysell-user
Forked from nepda/.gitignore
Last active February 7, 2019 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unifysell-user/4445ccf065a7e81671b1748c0706dd87 to your computer and use it in GitHub Desktop.
Save unifysell-user/4445ccf065a7e81671b1748c0706dd87 to your computer and use it in GitHub Desktop.
Complete basic working example for using the unifysell API with the PHP SDK. [unifysell Account required]
vendor/
composer.lock

Requirements

You will need a running PHP-7 installation.

Installation

  1. Get the code
    • git clone https://gist.github.com/unifysell-user/4445ccf065a7e81671b1748c0706dd87 unifysell-api-example
    • or download as zip and extract it
  2. Change directory into project cd unifysell-api-example/
  3. Get composer and install requirements sh unifysell-api-install.sh

Usage

run the example by executing the following:

php unifysell-api-get-order.php
{
"require": {
"unifysell/unifysell-sdk-php": "^0.2.4"
}
}
<?php
require_once 'vendor/autoload.php';
require_once 'unifysell-api-prepare-call.php';
$apiInstance = new Unifysell\SDK\Api\OrdersApi(
new GuzzleHttp\Client(),
$config
);
$firstOrder = $apiInstance->getOrder(1);
#!/bin/bash
curl -sS https://getcomposer.org/installer | php --
php composer.phar require unifysell/unifysell-sdk-php
<?php
require_once 'vendor/autoload.php';
// Build config - get your access token out of the unifysell control center
$config = Unifysell\SDK\Configuration::getDefaultConfiguration()->setApiKey(
'Authorization',
'<AccessToken>'
);
$config->setApiKeyPrefix('Authorization', 'Bearer');
<?php
require_once 'vendor/autoload.php';
require_once 'unifysell-api-prepare-call.php';
require_once 'unifysell-api-get-order.php';
//a short look inside the unifysell order
echo $firstOrder->getData()->getId();
# > 1
echo $firstOrder->getData()->getAmazonOrderId() . ' === ' . $firstOrder->getData()->getMarketplaceId();
# > 403-7788992-6789102 === 403-7788992-6789102
echo $firstOrder->getData()->getDateCreated();
# > 2018-11-11T15:23:15Z
echo $firstOrder->getData()->getStatus();
# > shipped
//another example
$secondOrder = $apiInstance->getOrder(2);
echo $secondOrder->getData()->getId();
# > 2
echo $secondOrder->getData()->getEbayOrderId() . ' === ' . $firstOrder->getData()->getMarketplaceId();
# > 161234567891-1456789101112 === 161234567891-1456789101112
echo $secondOrder->getData()->getDateCreated();
# > 2018-11-11T13:22:01Z
echo $secondOrder->getData()->getStatus();
# > paid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment