-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vendor/ | |
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"unifysell/unifysell-sdk-php": "^0.2.4" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -sS https://getcomposer.org/installer | php -- | |
php composer.phar require unifysell/unifysell-sdk-php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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