skip to Main Content

I am having trouble debugging this error i am recieving.
I tested the xml on the ebay developing site to see if it is valid and I recieved no errors
However when I attempt to send the xml file I receive an error.

PHP code:

function EbayVerifyAddItem($search)
{
    $url= utf8_encode("https://api.ebay.com/ws/api.dll");  //end point
    $xmlrequest = temp/xmlfile.xml; // link to xml file
    $xml = simplexml_load_file($xmlrequest);
    echo"<h3>Ebay Get Category</h3>";
    echo "URL: ".$url."<br>";

    $headers =  array(
    'X-EBAY-API-COMPATIBILITY-LEVEL: 901',
    'X-EBAY-API-DEV-NAME: productionDeveloperKey',
    'X-EBAY-API-SITEID: 3',
    'X-EBAY-API-CALL-NAME: VerifyAddItem',
    'Content-Type: text/xml');

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);    // set headers using $headers array
    curl_setopt($ch, CURLOPT_POST, true);              // POST request type
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); // set the body of the POST
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    // return values as a string, not to std out
    $content=curl_exec($ch);
    curl_close($ch); 

    echo "<br><br>";
    echo "Path to xml file: ".$xmlrequest."<br>"; 
    echo printf("content: %s",$content); 
    echo "<br><br>";

    return true;
}

xmlfile.xml:

<?xml version="1.0" encoding="utf-8"?>
<VerifyAddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <ErrorLanguage>en_US</ErrorLanguage>
  <WarningLevel>High</WarningLevel>
  <Item>
    <Title>Title</Title>
    <Description>Description</Description>
    <PrimaryCategory>
      <CategoryID>377</CategoryID>
    </PrimaryCategory>
    <StartPrice>1.00</StartPrice>
    <CategoryMappingAllowed>true</CategoryMappingAllowed>
    <ConditionID>1000</ConditionID>
    <Country>GB</Country>
    <Currency>GBP</Currency>
    <DispatchTimeMax>3</DispatchTimeMax>
    <ListingDuration>Days_7</ListingDuration>
    <ListingType>Chinese</ListingType>
    <PaymentMethods>PayPal</PaymentMethods>
    <PayPalEmailAddress>[email protected]</PayPalEmailAddress>
    <PictureDetails>
      <PictureURL>http://i1.sandbox.ebayimg.com/03/i/00/6b/63/03_1.JPG?set_id=8800005007 </PictureURL>
    </PictureDetails>
    <PostalCode>postcode</PostalCode>
    <Quantity>1</Quantity>
    <ShippingDetails>
      <ShippingType>Flat</ShippingType>
      <ShippingServiceOptions>
        <ShippingServicePriority>1</ShippingServicePriority>
        <ShippingService>UK_RoyalMailSecondClassRecorded</ShippingService>
        <ShippingServiceCost>2.50</ShippingServiceCost>
      </ShippingServiceOptions>
    </ShippingDetails>
    <Site>UK</Site>
  </Item>
  <RequesterCredentials>
    <eBayAuthToken>Token String Here</eBayAuthToken>
  </RequesterCredentials>
</VerifyAddItemRequest>

Error I receive:

Ebay Get Category
URL: https://api.ebay.com/ws/api.dll



Path to xml file: functions/tmp/Test.xml
content: 2015-08-15 21:00:07 100121SeriousError00RequestError 51SeriousError00RequestError 100111SeriousError00RequestError 100111SeriousError00RequestError 1115

Can anyone shed any light on where i am going wrong. If I can verify that the item will be successfully listed, I can go onto filling other details and list the item.

2

Answers


  1. The problem with your code is that you’re loading in your XML file as a PHP Object rather than a string. Instead of using the simple_xml_loadfile function which returns an object, use file_get_contents to read the xml file into the $xml variable:

    $xml = file_get_contents($xmlrequest);
    
    Login or Signup to reply.
  2. I am having trouble debugging this error i am recieving.

    The “error” you see is the XML without the tags as the browser filters them. You have to look into the source (view source feature in your browser) or encode it properly or even parse it already as XML and obtain the error information from it (makes most sense as you’re using an API).

    Most likely important information about the error got lost that way. Most prominent still seems:

    SeriousError00RequestError51
    

    For which no concrete error information can be obtained in the vendors documentation about the error codes (which specifies nearly all error codes), which shows you already prevented yourself so far to give a clear picture of the error.

    However most likely your problem is you have not understood that you need to pass XML as string to the service endpoint.

    While you verify the file contains valid XML by using an XML parser (which is good!), you miss to pass the XML as string to the webservice:

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    

    As $xml is not a string but a SimpleXMLElement (which would effectively trigger $xml->__toString() which return text-content and not the whole XML) the correct form would be to use the SimpleXMLElement::asXML() method on it:

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
    

    And that’s it already.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search