Created
June 8, 2016 13:29
-
-
Save davidtsadler/2b26c0baf001b3eca5765ad0a3865834 to your computer and use it in GitHub Desktop.
Getting an item by calling GetSingleItem in the Shopping API using the [eBay SDK for PHP](https://github.com/davidtsadler/ebay-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 __DIR__.'/vendor/autoload.php'; | |
use \DTS\eBaySDK\Constants; | |
use \DTS\eBaySDK\Shopping\Services; | |
use \DTS\eBaySDK\Shopping\Types; | |
use \DTS\eBaySDK\Shopping\Enums; | |
$service = new Services\ShoppingService([ | |
'credentials' => [ | |
'appId' => 'your-app-id', | |
'certId' => 'your-cert-id', | |
'devId' => 'your-dev-id' | |
], | |
'siteId' => Constants\SiteIds::GB | |
]); | |
$request = new Types\GetSingleItemRequestType(); | |
$request->ItemID = 'your-item-id'; | |
$request->IncludeSelector = 'Details,Description,ShippingCosts'; | |
$response = $service->getSingleItem($request); | |
if (isset($response->Errors)) { | |
foreach ($response->Errors as $error) { | |
printf( | |
"%s: %s\n%s\n\n", | |
$error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', | |
$error->ShortMessage, | |
$error->LongMessage | |
); | |
} | |
} | |
if ($response->Ack !== 'Failure') { | |
$item = $response->Item; | |
printf( | |
"%s\n%s\n%s\n%s\n%s\n(%s)%.2f\n", | |
$item->ViewItemURLForNaturalSearch, | |
$item->ItemID, | |
$item->Title, | |
$item->Description, | |
$item->Quantity, | |
$item->CurrentPrice->currencyID, | |
$item->CurrentPrice->value | |
); | |
print("Domestic Shipping Information\n"); | |
printf( | |
"(%s)%.2f\n", | |
$item->ShippingCostSummary->ShippingServiceCost->currencyID, | |
$item->ShippingCostSummary->ShippingServiceCost->value | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment