Skip to content

Instantly share code, notes, and snippets.

@davidtsadler
Last active June 1, 2017 10:44
Show Gist options
  • Save davidtsadler/1e6f375a0e48903002574dfdc5d1f2e7 to your computer and use it in GitHub Desktop.
Save davidtsadler/1e6f375a0e48903002574dfdc5d1f2e7 to your computer and use it in GitHub Desktop.
Getting an item by calling GetItem in the Trading API using the [eBay SDK for PHP](https://github.com/davidtsadler/ebay-sdk-php)
<?php
require __DIR__.'/vendor/autoload.php';
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Trading\Services;
use \DTS\eBaySDK\Trading\Types;
use \DTS\eBaySDK\Trading\Enums;
$service = new Services\TradingService([
'authToken' => 'your-auth-token',
'credentials' => [
'appId' => 'your-app-id',
'certId' => 'your-cert-id',
'devId' => 'your-dev-id'
],
'siteId' => Constants\SiteIds::GB
]);
$request = new Types\GetItemRequestType() ;
$request->ItemID = 'your-item-id';
$request->DetailLevel = ['ReturnAll'];
$response = $service->getItem($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->ListingDetails->ViewItemURL,
$item->ItemID,
$item->Title,
$item->Description,
$item->Quantity,
$item->SellingStatus->CurrentPrice->currencyID,
$item->SellingStatus->CurrentPrice->value
);
print("Domestic Shipping Information\n");
foreach ($item->ShippingDetails->ShippingServiceOptions as $shipping) {
printf(
"[%s] (%s)%.2f\n",
$shipping->ShippingService,
$shipping->ShippingServiceCost->currencyID,
$shipping->ShippingServiceCost->value
);
}
}
@baldau
Copy link

baldau commented Jun 1, 2017

plz give me idea how to use this api

@baldau
Copy link

baldau commented Jun 1, 2017

vendor autload php did not fined on your sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment