Last active
June 1, 2017 10:44
-
-
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)
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\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 | |
); | |
} | |
} |
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
plz give me idea how to use this api