title: Getting xml response from ebay api
body: <p>I have created code to get the response from ebay. I tested using sandbox in ebay, which gives correct result. </p>
  
  <p>but here in localhost example it does not give response:</p>
  
  <p>For below code when I do: </p>
  
  <pre><code>$xmlResponse = simplexml_load_string($response);
  var_dump($xmlResponse);
  </code></pre>
  
  <p>it returns : <code>false</code>;</p>
  
  <p>any idea what can be wrong here?</p>
  
  <p>code:</p>
  
  <pre><code>require_once 'tradingConstants.php';
  //DEFINE("API_URL",'https://api.sandbox.ebay.com/ws/api.dll');
  
  
  
  // check if posted
  
      // grab our posted keywords and call helper function
      // TODO: check if need urlencode
      $title = $_POST['title'];
      $categoryID = $_POST['categoryID'];
      $startPrice = $_POST['startPrice'];
      $pictureURL = $_POST['pictureURL'];
      $description = $_POST['description'];
  
      // call the getAddItem function to make AddItem call
    $response = getAddItem($title, $categoryID, $startPrice, $pictureURL, $description);
  // Function to call the Trading API AddItem
  
  function getAddItem($addTitle, $addCatID, $addSPrice, $addPicture, $addDesc) {
  
      /* Sample XML Request Block for minimum AddItem request
      see ... for sample XML block given length*/
  
      // Create unique id for adding item to prevent duplicate adds
      $uuid = md5(uniqid());
  
      // create the XML request
      $xmlRequest  = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;";
      $xmlRequest .= "&lt;AddItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\"&gt;";
      $xmlRequest .= "&lt;ErrorLanguage&gt;en_US&lt;/ErrorLanguage&gt;";
    $xmlRequest .= "&lt;WarningLevel&gt;High&lt;/WarningLevel&gt;";
    $xmlRequest .= "&lt;Item&gt;";
    $xmlRequest .= "&lt;Title&gt;" . $addTitle . "&lt;/Title&gt;";
    $xmlRequest .= "&lt;Description&gt;" . $addDesc . "&lt;/Description&gt;";
    $xmlRequest .= "&lt;PrimaryCategory&gt;";
    $xmlRequest .= "&lt;CategoryID&gt;" . $addCatID . "&lt;/CategoryID&gt;";
    $xmlRequest .= "&lt;/PrimaryCategory&gt;";
    $xmlRequest .= "&lt;StartPrice&gt;" . $addSPrice . "&lt;/StartPrice&gt;";
    $xmlRequest .= "&lt;ConditionID&gt;1000&lt;/ConditionID&gt;";
    $xmlRequest .= "&lt;CategoryMappingAllowed&gt;true&lt;/CategoryMappingAllowed&gt;";
    $xmlRequest .= "&lt;Country&gt;US&lt;/Country&gt;";
    $xmlRequest .= "&lt;Currency&gt;USD&lt;/Currency&gt;";
    $xmlRequest .= "&lt;DispatchTimeMax&gt;3&lt;/DispatchTimeMax&gt;";
    $xmlRequest .= "&lt;ListingDuration&gt;Days_7&lt;/ListingDuration&gt;";
    $xmlRequest .= "&lt;ListingType&gt;Chinese&lt;/ListingType&gt;";
    $xmlRequest .= "&lt;PaymentMethods&gt;PayPal&lt;/PaymentMethods&gt;";
    $xmlRequest .= "&lt;PayPalEmailAddress&gt;yourpaypal@emailaddress.com&lt;/PayPalEmailAddress&gt;";
    $xmlRequest .= "&lt;PictureDetails&gt;";
    $xmlRequest .= "&lt;PictureURL&gt;" . $addPicture . "&lt;/PictureURL&gt;";
    $xmlRequest .= "&lt;/PictureDetails&gt;";
    $xmlRequest .= "&lt;PostalCode&gt;05485&lt;/PostalCode&gt;";
    $xmlRequest .= "&lt;Quantity&gt;1&lt;/Quantity&gt;";
    $xmlRequest .= "&lt;ReturnPolicy&gt;";
    $xmlRequest .= "&lt;ReturnsAcceptedOption&gt;ReturnsAccepted&lt;/ReturnsAcceptedOption&gt;";
    $xmlRequest .= "&lt;RefundOption&gt;MoneyBack&lt;/RefundOption&gt;";
    $xmlRequest .= "&lt;ReturnsWithinOption&gt;Days_30&lt;/ReturnsWithinOption&gt;";
    $xmlRequest .= "&lt;Description&gt;" . $addDesc . "&lt;/Description&gt;";
    $xmlRequest .= "&lt;ShippingCostPaidByOption&gt;Buyer&lt;/ShippingCostPaidByOption&gt;";
    $xmlRequest .= "&lt;/ReturnPolicy&gt;";
    $xmlRequest .= "&lt;ShippingDetails&gt;";
    $xmlRequest .= "&lt;ShippingType&gt;Flat&lt;/ShippingType&gt;";
    $xmlRequest .= "&lt;ShippingServiceOptions&gt;";
      $xmlRequest .= "&lt;ShippingServicePriority&gt;1&lt;/ShippingServicePriority&gt;";
    $xmlRequest .= "&lt;ShippingService&gt;USPSMedia&lt;/ShippingService&gt;";
    $xmlRequest .= "&lt;ShippingServiceCost&gt;2.50&lt;/ShippingServiceCost&gt;";
    $xmlRequest .= "&lt;/ShippingServiceOptions&gt;";
    $xmlRequest .= "&lt;/ShippingDetails&gt;";
    $xmlRequest .= "&lt;Site&gt;US&lt;/Site&gt;";
    $xmlRequest .= "&lt;UUID&gt;" . $uuid . "&lt;/UUID&gt;";
    $xmlRequest .= "&lt;/Item&gt;";
    $xmlRequest .= "&lt;RequesterCredentials&gt;";
    $xmlRequest .= "&lt;eBayAuthToken&gt;" . AUTH_TOKEN . "&lt;/eBayAuthToken&gt;";
    $xmlRequest .= "&lt;/RequesterCredentials&gt;";
    $xmlRequest .= "&lt;WarningLevel&gt;High&lt;/WarningLevel&gt;";
      $xmlRequest .= "&lt;/AddItemRequest&gt;";
  
      // define our header array for the Trading API call
      // notice different headers from shopping API and SITE_ID changes to SITEID
      $headers = array(
          /*'X-EBAY-API-SITEID:'.SITEID,
          'X-EBAY-API-CALL-NAME:addItem',
          'X-EBAY-API-REQUEST-ENCODING:XML',
          'X-EBAY-API-COMPATIBILITY-LEVEL:' . API_COMPATIBILITY_LEVEL,
          'X-EBAY-API-DEV-NAME:' . API_DEV_NAME,
          'X-EBAY-API-APP-NAME:' . API_APP_NAME,
          'X-EBAY-API-CERT-NAME:' . API_CERT_NAME,*/
  
          'X-EBAY-API-APP-ID:Startupb1-efb9-43ca-a0e8-473753fe9ad,
          X-EBAY-API-VERSION:863,
          X-EBAY-API-SITE-ID:203,
          X-EBAY-API-CALL-NAME:AddItem,
          X-EBAY-API-REQUEST-ENCODING:XML,
          Content-Type: text/xml;charset=utf-8'
      );
      $API_URL = 'https://api.sandbox.ebay.com/ws/api.dll';
      // initialize our curl session
      $session  = curl_init();
      curl_setopt($session, CURLOPT_URL, $API_URL);
      // set our curl options with the XML request
      curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($session, CURLOPT_POST, true);
      curl_setopt($session, CURLOPT_POSTFIELDS, $xmlRequest);
      curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  
      // execute the curl request
      $responseXML = curl_exec($session);
  
      // close the curl session
      curl_close($session);
      //echo $addTitle;
      // return the response XML
      return $responseXML;
  }
  </code></pre>