Installation
composer require d4m/ebay-bundle
Register the bundle in config/bundles.php (Symfony 4.4+):
return [
// ...
D4m\EbayBundle\D4mEbayBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console d4m:ebay:install
Update config/packages/d4m_ebay.yaml with your API credentials (App ID, Dev ID, Cert ID, Token).
First Use Case Fetch active listings via CLI:
php bin/console d4m:ebay:listings:active
Or programmatically:
use D4m\EbayBundle\Service\EbayService;
$ebay = $this->get('d4m_ebay.ebay_service');
$listings = $ebay->getActiveListings();
API Integration
EbayService for core operations (e.g., getActiveListings(), createListing()).['Item.Specifics'] => [...]).$ebay->createListing([
'Item' => [
'Title' => 'Test Product',
'CategoryID' => '12345',
'StartPrice' => '19.99',
],
]);
Event-Driven Extensions
ebay.listing.created) via Symfony’s event dispatcher:
$dispatcher->addListener('ebay.listing.created', function ($event) {
// Log or process the new listing
});
Command-Line Automation
d4m:ebay:listings:sync) via Laravel’s task scheduler:
$schedule->command('d4m:ebay:listings:sync')->daily();
Response Handling
EbayResponse:
$response = $ebay->getOrderDetails(['OrderID' => '123']);
if ($response->isSuccess()) {
$data = $response->getData();
}
EbayService to Laravel’s container in AppServiceProvider:
$this->app->bind('d4m_ebay.ebay_service', function ($app) {
return new EbayService($app['d4m_ebay.config']);
});
EbayService in unit tests:
$mock = $this->createMock(EbayService::class);
$mock->method('getActiveListings')->willReturn([...]);
$this->app->instance('d4m_ebay.ebay_service', $mock);
Authentication Failures
d4m_ebay.yaml:
debug: true
Check logs for EbayException details.Rate Limits
try {
$ebay->getActiveListings();
} catch (RateLimitException $e) {
sleep($e->getRetryAfter());
retry();
}
Deprecated Methods
getItem → findItemsAdvanced).class CustomEbayService extends EbayService {
public function findItemsAdvanced(array $params) {
return $this->callApi('findItemsAdvanced', $params);
}
}
XML vs. JSON
response_format: json
Enable Verbose Logging:
logging: true
Logs appear in var/log/d4m_ebay.log.
Validate XML:
Use php bin/console d4m:ebay:validate-xml to check request payloads.
Custom API Calls
Extend EbayService to add unsupported endpoints:
public function getMyeBaySelling($callName, array $params) {
return $this->callApi('GetMyeBaySelling', $params, 'MyeBaySelling');
}
Response Transformers
Override EbayResponse to customize data structures:
class CustomEbayResponse extends EbayResponse {
public function transform() {
return collect($this->data)->map(fn ($item) => [
'title' => $item->Title,
'price' => $item->CurrentPrice,
]);
}
}
Event Listeners Add listeners for real-time processing (e.g., webhooks):
// config/packages/d4m_ebay.yaml
listeners:
ebay.listing.updated: App\Listener\EbayListingUpdatedListener
How can I help you explore Laravel packages today?