Skip to content

Instantly share code, notes, and snippets.

@nepda
Forked from ThomasRueckert/unifysell-api-install.sh
Last active October 31, 2018 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nepda/43e403e3ac5b79aef4c37c303d05c114 to your computer and use it in GitHub Desktop.
Save nepda/43e403e3ac5b79aef4c37c303d05c114 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
{
"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);
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
$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
#!/bin/bash
curl -sS https://getcomposer.org/installer | php --
php composer.phar require unifysell/unifysell-sdk-php
<?php
require_once 'vendor/autoload.php';
// Authenticate
$keycloakClient = new \Unifysell\OAuth2\Client\Keycloak();
$accessToken = $keycloakClient->createAccessToken();
// Build config
$config = Unifysell\SDK\Configuration::getDefaultConfiguration()->setApiKey(
'Authorization',
$keycloakClient->getAccessToken()->getToken()
);
$config->setApiKeyPrefix('Authorization', 'Bearer');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment