title: eBay Trading API PHP XML call fails (Ack failure)
body: <p>So I can't seem to get this code working.  I used a very similar code under the Finding API that works great, made the appropriate changes (endpoint, header, etc.) for the Trading API, and now it won't work.  In using the eBay API Test Tool, everything seems fine, so I'm not sure what the issue may be.  </p>
  
  <p>Can anyone provide insight?  The ack returns failure instead of success.  My PHP has curl enabled and that is not the issue either.  Thank you in advance!</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);  // Turn on all errors, warnings, and notices for easier debugging
  
  // API request variables
  $endpoint = 'https://api.ebay.com/ws/api.dll';  // URL to call
  $query = 'username';                  // Supply your own query keywords as needed
  
  // Construct the findItemsByKeywords POST call
  $resp = simplexml_load_string(constructPostCallAndGetResponse($endpoint, $query));
  
  // Check to see if the call was successful, else print an error
  if ($resp-&gt;ack == "Success") {
    $results = '';  // Initialize the $results variable
  
    // Parse the desired information from the response
    foreach($resp-&gt;searchResult-&gt;item as $item) {
      $pic   = $item-&gt;galleryURL;
      $link  = $item-&gt;viewItemURL;
      $price = $item-&gt;sellingStatus-&gt;currentPrice;    
      $title = $item-&gt;title;
  
      // Build the desired HTML code for each searchResult.item node and append it to $results
      $results .= "&lt;tr&gt;&lt;td&gt;&lt;img src=\"$pic\"&gt;&lt;/td&gt;&lt;td&gt;$price&lt;/td&gt;&lt;td&gt;&lt;a href=\"$link\"&gt;$title&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;";
    }
  }
  else {  // If the response does not indicate 'Success,' print an error
    $results  = "&lt;h3&gt;Oops! The request was not successful.";
  }
  
  ?&gt;
  
  &lt;!-- Build the HTML page with values from the call response --&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;eBay Search Results for &lt;?php echo $query; ?&gt;&lt;/title&gt;
  &lt;style type="text/css"&gt;body { font-family: arial,sans-serif;} &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;eBay Search Results for &lt;?php echo $query; ?&gt;&lt;/h1&gt;
  
  &lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;?php echo $results;?&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php
  
  function constructPostCallAndGetResponse($endpoint, $query) {
    global $xmlrequest;
  
    // Create the XML request to be POSTed
    $xmlrequest  = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n";
    $xmlrequest .= "&lt;GetBidderListRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\"&gt;\n";
    $xmlrequest .= "&lt;RequesterCredentials&gt;\n &lt;eBayAuthToken&gt;xxxxxxxxxxx&lt;/eBayAuthToken&gt;&lt;/RequesterCredentials&gt;\n";
    $xmlrequest .= "&lt;UserID&gt;";
    $xmlrequest .= $query;
    $xmlrequest .= "&lt;/UserID&gt;\n";
    $xmlrequest .= "&lt;/GetBidderListRequest&gt;";
  
    // Set up the HTTP headers
    $headers = array(
      'X-EBAY-API-COMPATIBILITY-LEVEL:951',
      'X-EBAY-API-DEV-NAME:xxxxxxxxxx',
      'X-EBAY-API-APP-NAME:xxxxxxxxxx',
      'X-EBAY-API-CERT-NAME:xxxxxxxxxx',
      'X-EBAY-API-SITEID:0',
      'X-EBAY-API-CALL-NAME:GetBidderList'
    );
  
    $session  = curl_init($endpoint);                       // create a curl session
    curl_setopt($session, CURLOPT_POST, true);              // POST request type
    curl_setopt($session, CURLOPT_HTTPHEADER, $headers);    // set headers using $headers array
    curl_setopt($session, CURLOPT_POSTFIELDS, $xmlrequest); // set the body of the POST
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);    // return values as a string, not to std out
  
    $responsexml = curl_exec($session);                     // send the request
    curl_close($session);                                   // close the session
    return $responsexml;                                    // returns a string
  
  }  // End of constructPostCallAndGetResponse function
  
  ?&gt;
  </code></pre>