Skip to content

Instantly share code, notes, and snippets.

@davidtsadler
Created June 8, 2016 13:26
Show Gist options
  • Save davidtsadler/71843104270384ce971b8ba184944eae to your computer and use it in GitHub Desktop.
Save davidtsadler/71843104270384ce971b8ba184944eae to your computer and use it in GitHub Desktop.
Getting an item by calling findItemsAdvanced in the Finding 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\Finding\Services;
use \DTS\eBaySDK\Finding\Types;
use \DTS\eBaySDK\Finding\Enums;
$service = new Services\FindingService([
'credentials' => [
'appId' => 'your-app-id',
'certId' => 'your-cert-id',
'devId' => 'your-dev-id'
],
'globalId' => Constants\GlobalIds::GB
]);
$request = new Types\FindItemsAdvancedRequest();
$request->keywords = 'your-item-id';
$response = $service->findItemsAdvanced($request);
if (isset($response->errorMessage)) {
foreach ($response->errorMessage->error as $error) {
printf(
"%s: %s\n\n",
$error->severity=== Enums\ErrorSeverity::C_ERROR ? 'Error' : 'Warning',
$error->message
);
}
}
if ($response->ack !== 'Failure') {
$item = $response->searchResult->item[0];
printf(
"%s\n%s\n%s\n(%s)%.2f\n",
$item->viewItemURL,
$item->itemId,
$item->title,
$item->sellingStatus->currentPrice->currencyId,
$item->sellingStatus->currentPrice->value
);
print("Domestic Shipping Information\n");
printf(
"(%s)%.2f\n",
$item->shippingInfo->shippingServiceCost->currencyId,
$item->shippingInfo->shippingServiceCost->value
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment