I wrote a simple PHP script that retrieves an item from eBay. I’m using PHP and SOAP. I can get the items with other calls just fine. However, I need to use the findItemsAdvanced
call to get items from a seller, but I haven’t been able to make it work.
Here’s what I have so far:
function call_ebay_id_api($itemID){
$location = 'http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=****8&OPERATION-NAME=findItemsAdvanced&itemFilter(0).name=Seller&itemFilter(0).value=****';
$clientebay = new SoapClient(
"http://developer.ebay.com/webservices/Finding/latest/FindingService.wsdl",
array(
"exceptions" => 0,
"trace" => 1,
"location"=> $location
)
);
$requestebay = array("itemFilter" => array("name" => "Seller", "value" => "****"));
$xmlresultsebay = $clientebay->__soapCall('findItemsAdvanced', array($requestebay));
echo "REQUEST HEADERS:n<pre>" . htmlentities($clientebay->__getLastRequestHeaders()) . "</pre>n";
echo "REQUEST:n<pre>" . htmlentities($clientebay->__getLastRequest()) . "</pre>n";
echo "RESPONSE:n<pre>" . htmlentities($clientebay->__getLastResponse()) . "</pre>n";
echo 'd';
return $xmlresultsebay;
and the XML request from this is:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.ebay.com/marketplace/search/v1/services">
<SOAP-ENV:Body>
<ns1:findItemsAdvancedRequest>
<itemFilter>
<name>Seller</name>
<value>*seller name here*</value>
</itemFilter>
</ns1:findItemsAdvancedRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
which looks like the example they have on the API’s page
However, the response that I got back is an error. It says I need to specify keywords or category ID. When I do that, I get success, but the itemFilter
isn’t applied.
Can anyone help me here?
2
Answers
Mkay so I got it working...I guess?
So I thought the problem was that eBay's itemFilter requires an ItemFilter type (notice the capital I in the ItemFilter, btw), instead of an array. This led me to create classes with the same names as the types required for the request call. So I created objects called ItemFilter, Name, Value, etc. However, it still didn't work.
I almost gave up and start over maybe with cURL or something...or even Cajun voodoo since nothing else worked, so hey, why not magic?
After I went to the cemetery of Madam Marie Laveau with a piece of alligator skin and some boudin links to put on her grave, I got really hungry and started thinking about the boudin. "Hmm...delicious rice and pig offal inside the pig intestine wrapper...hold on," I thought to myself "wrapper? I should check if the variable is wrapped correctly." So after I got home (with some more boudin from the local market), I checked the wrapper and it was correct. But then I noticed that the namespace for the itemFilter was missing. So I started messing around with PHP SoapVar...and it worked! "Finally, a dim spark in this god forsaken web-dev abyss," so I thought.
So basically instead of:
I should've put:
...and BAM! that solved my problem. I guess the lesson to be learned here is that voodoo is a whole lot better than eBay's documentation, since with voodoo I don't have to dig very deep to find things for my next project.
Instead of building a Soapvar for every variable
create a subclass of SoapClient
example call:
not the most eloquent but works for me, you can scrap the namespace if you want just put it up there for illustrative purposes. It sets the default namespace.