Zend_Service_Ebay | Zend_Service Programmer's Reference Guide | Zend_Service_Flickr

# Zend_Service_Ebay_Finding

# Introduction

Zend_Service_Ebay_Finding provides a client for the » eBay Finding. Per eBay website, "The Finding API provides programmatic access to the next generation search capabilities on the eBay platform. It lets you search and browse for items listed on eBay, and provides useful metadata to refine searches and enhance the search experience."

In order to use Zend_Service_Ebay_Finding, you should already have an eBay Application ID. To get a key and for more information, please visit the » eBay Developers Program web site.

# Create a client object

Instantiate a Zend_Service_Ebay_Finding object, passing it your private keys:

Example #1 Creating an instance of the eBay Finding service

1. $finding = new Zend_Service_Ebay_Finding('my-app-id');

Instantiate a Zend_Service_Ebay_Finding object, passing it your private keys and setting options:

Example #2 Creating an instance of the eBay Finding service

1. $options = array (Zend_Service_Ebay_Abstract::OPTION_APP_ID => 'my-app-id',
2. Zend_Service_Ebay_Abstract::OPTION_GLOBAL_ID => 'EBAY-GB');
3. $finding = new Zend_Service_Ebay_Finding($options);

# Finding items

There are five available methods to search items:

- findItemsByKeywords($keywords)

- findItemsByProduct($productId)

- findItemsByCategory($categoryId)

- findItemsAdvanced($keywords)

- findItemsInEbayStores($storeName)

Example #3 Many ways to find items

1. $finding = new Zend_Service_Ebay_Finding('my-app-id');
2. $response = $finding->findItemsByKeywords('zend framework book');
3. foreach ($response->searchResult->item as $item) {
4. $item->title;
5. $item->listingInfo->buyItNowPrice;
6. $item->listingInfo->viewItemURL;
8. // inner call, find for items of same current product
9. // like $finding->findItemsByProduct($item->productId, $item->attributes('productId', 'type'))
10. $response2 = $item->findItemsByProduct($finding);
12. // inner call, find for items of same store
13. // like $finding->findItemsInEbayStores($item->storeInfo->storeName)
14. $response3 = $item->storeInfo->findItems($finding);
15. }

# Keywords Recommendation

This operation checks specified keywords and returns correctly spelled keywords for best search results.

Example #4 Searching keywords recomendation

1. // searching keywords
2. $finding = new Zend_Service_Ebay_Finding('my-app-id');
3. $result = $finding->getSearchKeywordsRecommendation('zend');
4. echo 'Did you mean ' . $result->keyword . '?';
6. // inner call
7. // like $finding->findItemsByKeywords($result->keyword)
8. $result2 = $result->findItems($finding);

# Histograms

Per eBay website, this operation "category and/or aspect histogram information for the eBay category ID you specify. Histograms are item counts for the associated category or aspect value. Input category ID numbers in the request using the categoryId field".

Example #5 Fetching histogram

1. $finding = new Zend_Service_Ebay_Finding('my-app-id');
2. $result = $finding->getHistograms($categoryId);
4. foreach ($result->categoryHistogramContainer->categoryHistogram as $category) {
5. $category->categoryId;
6. $category->categoryName;
8. // inner call
9. // like $finding->findItemsByCategory($category->categoryId);
10. $result2 = $category->findItems($finding);
11. }

Zend_Service_Ebay | Zend_Service Programmer's Reference Guide | Zend_Service_Flickr