janikivisola avatar image
janikivisola asked

PHP + XML query produces error


Hello! A while back I coded a working php application for getting eBay items through word search, similar items and item id. Today I went back to use the application and noticed it gives me a XML error.

In the developer api tool I get success, but using php not. I use Win 7 64-bit + Apache + PHP + cUrl.

When doing a search query using everything goes alright, but switching to and GetSingleItem I can't get success. Been googling a lot with no help.

Please somebody explain why once a working code does not work anymore. I haven't changed anything. 

Except, I have reinstalled my Windows and Apache. It might be the reason? Some Apache settings do weird things to headers or XML?

Here's a sample request that does not work:
<?xml version="1.0" encoding="utf-8"?>
<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<IncludeSelector>Details, TextDescription,ItemSpecifics</IncludeSelector>

and headers are:

(API ID is obviously my id)

curl_getinfo CURLINFO_HEADER_OUT gives back this:
POST /shopping? HTTP/1.0
Accept: */*
Content-Length: 245
Content-Type: application/x-www-form-urlencoded

This is the XML response I get:

<GetSingleItemResponse xmlns="">

   <ns1:Ack xmlns:ns1="urn:ebay:apis:eBLBaseComponents">Failure</ns1:Ack>

   <ns2:Errors xmlns:ns2="urn:ebay:apis:eBLBaseComponents">

    <ns2:ShortMessage>Input data is invalid.</ns2:ShortMessage>

    <ns2:LongMessage>Input data for the given tag is invalid or missing. Please check API documentation.</ns2:LongMessage>



    <ns2:ErrorParameters ParamID="0">

     <ns2:Value>XML document structures must start and end within the same entity.</ns2:Value>




   <ns3:Build xmlns:ns3="urn:ebay:apis:eBLBaseComponents">E771_CORE_BUNDLED_14784928_R1</ns3:Build>

   <ns4:Version xmlns:ns4="urn:ebay:apis:eBLBaseComponents">771</ns4:Version>


I repeat that ebay dev api tool gives success, but php does not and previously it gave success as well, but not anymore.

10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

helios825 avatar image
helios825 answered

I don't think I've ever POSTed a GetSingleItem request before. But looking over the error messages you got, it seems like a problem with the structure of the input XML you are sending. My hunch is that it's something really simple, like a closing tag or similar. For example, the first thing I'd try is removing the superfluous space within the IncludeSelector string.

10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.