|
|
|
|
How to use findItemsIneBayStores-finding API
Posted:
Nov 17, 2009 3:15 AM
|
|
Hi,
I have to implement the finding API. I have tried to implement it,but with no success.
<?php
error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging
// API request variables $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; // URL to call $version = '1.0.0'; // API version supported by your application $appid = ''; // Replace with your own AppID $globalid = 'EBAY-GB'; // Global ID of the eBay site you want to search (e.g., EBAY-DE) $query = 'BMW'; // You will need to supply your own query $SafeQuery = urlencode($query); // Make the query URL-friendly $storenname = 'xyz'; // Initialize the item filter index array to 0 $i = '0'; // Initialize the item filter index array to 0
$filterArray = array( array( 'name' => 'MaxPrice', 'value' => '250', 'paramName' => 'Currency', 'paramValue' => 'GBP'), array( 'name' => 'FreeShippingOnly', 'value' => 'false', 'paramName' => '', 'paramValue' => ''), );
// Build item filters URL array function buildURLArray ($filterArray) { global $urlfilter; global $i; // Iterate through each filter in the array foreach($filterArray as $itemFilter) { // Iterate through each key in the filter foreach ($itemFilter as $key =>$value) { $r = '0'; //A number that increments each time the above "for" loops; if(is_array($value)) { //if the 'value' var content is an array if($value != "") { //check to make sure the content isn't empty foreach($value as $j => $content) { $urlfilter .= "&itemFilter($i).$key($j)=$content"; } } } else { //this isnt an array so just print the single contents of the 'value' container, no indexing of keys needed if($value != "") { $urlfilter .= "&itemFilter($i).$key=$value"; } } $r++; } $i++; } return "$urlfilter"; } // End of buildURLArray function
buildURLArray($filterArray);
// Construct the findItemsByKeywords call $apicall = "$endpoint?"; $apicall .= "OPERATION-NAME=findItemsIneBayStores"; $apicall .= "&SERVICE-VERSION=$version"; $apicall .= "&SECURITY-APPNAME=$appid"; $apicall .= "&RESPONSE-DATA-FORMAT=XML"; $apicall .= "&REST-PAYLOAD";
$apicall .= "&GLOBAL-ID=$globalid"; $apicall .= "&storeName=$storenname"; $apicall .= "&outputSelector=StoreInfo";
$apicall .= "$urlfilter"; $apicall .= "&paginationInput.entriesPerPage=1"; $apicall .= "&keywords=$SafeQuery";
// Load the call and capture the document returned by eBay API $resp = simplexml_load_file($apicall); print_r($resp);
but while printing the rseult I am getting
SimpleXMLElement Object ( [ack] => Success [version] => 1.1.0 [timestamp] => 2009-11-17T11:10:36.349Z [searchResult] => SimpleXMLElement Object ( [@attributes] => Array ( [count] => 0 ) ) [paginationOutput] => SimpleXMLElement Object ( [pageNumber] => 0 [entriesPerPage] => 1 [totalPages] => 0 [totalEntries] => 0 ) )
where have I gone wrong. Some one please help me out. I am really stuck over here
Thanks Aneesh.V.K
|
|
|
|
|
|
Re: How to use findItemsIneBayStores-finding API
Posted:
Nov 17, 2009 1:28 PM
|
|
set the storename variable
|
|
|
|
|
|
Re: How to use findItemsIneBayStores-finding API
Posted:
Nov 17, 2009 10:39 PM
|
|
Thanks for the reply...
i was able to make the call work
this the working call
<?php
error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging
// API request variables
$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; // URL to call
$version = '1.1.0'; // API version supported by your application
$appid = 'Your appid'; // Replace with your own AppID
$globalid = 'EBAY-GB'; // Global ID of the eBay site you want to search (e.g., EBAY-DE)
$query = 'BMW'; // You will need to supply your own query
$SafeQuery = urlencode($query); // Make the query URL-friendly
$storenname = 'your store name';
$i = '0'; // Initialize the item filter index array to 0
$filterArray =
array(
array(
'name' => 'MaxPrice',
'value' => '250',
'paramName' => 'Currency',
'paramValue' => 'GBP'),
array(
'name' => 'FreeShippingOnly',
'value' => 'false',
'paramName' => '',
'paramValue' => ''),
);
// Build item filters URL array
function buildURLArray ($filterArray) {
global $urlfilter;
global $i;
// Iterate through each filter in the array
foreach($filterArray as $itemFilter) {
// Iterate through each key in the filter
foreach ($itemFilter as $key =>$value) {
$r = '0'; //A number that increments each time the above "for" loops;
if(is_array($value)) { //if the 'value' var content is an array
if($value != "") { //check to make sure the content isn't empty
foreach($value as $j => $content) {
$urlfilter .= "&itemFilter($i).$key($j)=$content";
}
}
}
else { //this isnt an array so just print the single contents of the 'value' container, no indexing of keys needed
if($value != "") {
$urlfilter .= "&itemFilter($i).$key=$value";
}
}
$r++;
}
$i++;
}
return "$urlfilter";
} // End of buildURLArray function
buildURLArray($filterArray);
// Construct the findItemsByKeywords call
$apicall = "$endpoint?";
$apicall .= "OPERATION-NAME=findItemsIneBayStores";
$apicall .= "&SERVICE-VERSION=$version";
$apicall .= "&SECURITY-APPNAME=$appid";
$apicall .= "&RESPONSE-DATA-FORMAT=XML";
$apicall .= "&REST-PAYLOAD";
$apicall .= "&GLOBAL-ID=$globalid";
$apicall .= "&storeName=$storenname";
$apicall .= "&outputSelector=StoreInfo";
$apicall .= "$urlfilter";
$apicall .= "&paginationInput.entriesPerPage=4";
//echo $apicall." ";
// Load the call and capture the document returned by eBay API
$resp = simplexml_load_file($apicall);
print_r($resp);
// Check to see if the response was loaded, else print an error
if ($resp) {
$results = '';
// If the response was loaded, parse it and build links
foreach($resp->searchResult->item as $item) {
$pic = $item->galleryURL;
$link = $item->viewItemURL;
$title = $item->title;
// For each SearchResultItem node, build a link and append it to $results
$results .= "<tr><td> </td><td>$title</td></tr>";
foreach($item->sellingStatus as $sellingStatus) {
$priceOfMoreItems = $sellingStatus->currentPrice;
}
}
}
// If there was no response, print an error
else {
$results = "Oops! Must not have gotten the response!";
}
?>
But now I have got another issue. This call only returns 100 items. I have to get about 2000 items. How can I do that.Is there any other methods for getting all the items from a store
Thanks
Aneesh
|
|
|