question

janikivisola avatar image
0 Likes"
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 http://svcs.ebay.com/services/search/FindingService/v1 everything goes alright, but switching to http://open.api.ebay.com/shopping? 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">
<ItemID>110871394582</ItemID>
<IncludeSelector>Details, TextDescription,ItemSpecifics</IncludeSelector>
</GetSingleItemRequest>

and headers are:

X-EBAY-API-APP-ID:xxxx,
X-EBAY-API-VERSION:705,
X-EBAY-API-SITE-ID:0,
X-EBAY-API-REQUEST-ENCODING:XML,
X-EBAY-API-CALL-NAME:GetSingleItem
(API ID is obviously my id)

curl_getinfo CURLINFO_HEADER_OUT gives back this:
POST /shopping? HTTP/1.0
Host: open.api.ebay.com
Accept: */*
X-EBAY-API-APP-ID:xxxx
X-EBAY-API-VERSION:705
X-EBAY-API-SITE-ID:0
X-EBAY-API-REQUEST-ENCODING:XML
X-EBAY-API-CALL-NAME:GetSingleItem
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:ErrorCode>1.22</ns2:ErrorCode>

    <ns2:SeverityCode>Error</ns2:SeverityCode>

    <ns2:ErrorParameters ParamID="0">

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

    </ns2:ErrorParameters>

    <ns2:ErrorClassification>RequestError</ns2:ErrorClassification>

   </ns2:Errors>

   <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>

  </GetSingleItemResponse>

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

xml-php-curl
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
0 Likes"
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.