title: Getting multiple items from eBay with Single item API shows ERROR
body: <p>I'm using eBay <strong>Single item API</strong> to get details for selected items.
  I know eBay have multiple-item API also but it will not give all the details I want.</p>
  
  <hr>
  
  <p>I have a Var <code>$gpd</code> where I have item numbers. Then using <code>explode</code> to make Array <code>$items</code></p>
  
  <p>Then using <code>foreach</code> to run eBay Single item API for all items in Array.</p>
  
  <p>Then added 20% profit and roundup the price.</p>
  
  <p>Then making static PayPal button.</p>
  
  <hr>
  
  <p>My code below works perfect mostly of the time. But sometimes it shows ONLY the 2 first items in Array and then shows the ERROR:</p>
  
  <pre><code>$xml=simplexml_load_string($response) or die("Error: Could not get item");
  </code></pre>
  
  <p>If I again reload the page then it shows all the items in Array and everything works perfectly.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>&lt;?php
  $gpd = '281616878215, 221694130228, 191506118709, 271806308878, 231451119156' ;
  $items = explode(', ', $gpd);
  $profit = "1.2";
  function round_up ($value, $places=0) {
    if ($places &lt; 0) { $places = 0; }
    $mult = pow(10, $places);
    return ceil($value * $mult) / $mult;
  }
  
  foreach($items as $item) {
  $appID = 'HERE-NEED-TO-PUT-EBAY-APPID';
  $exexex = $item;
  $request = '&lt;?xml version="1.0" encoding="utf-8"?&gt;
              &lt;GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents" &gt;
              &lt;ItemID&gt;'.$exexex.'&lt;/ItemID&gt;
              &lt;IncludeSelector&gt;Details,ShippingCosts,ItemSpecifics,Variations&lt;/IncludeSelector&gt;
              &lt;/GetSingleItemRequest&gt;';
  $callName = 'GetSingleItem';
  $compatibilityLevel = 647;
  $endpoint = "http://open.api.ebay.com/shopping";
  $headers[] = "X-EBAY-API-CALL-NAME: $callName";
  $headers[] = "X-EBAY-API-APP-ID: $appID";
  $headers[] = "X-EBAY-API-VERSION: $compatibilityLevel";
  $headers[] = "X-EBAY-API-REQUEST-ENCODING: XML";
  $headers[] = "X-EBAY-API-RESPONSE-ENCODING: XML";
  $headers[] = "X-EBAY-API-SITE-ID: 0";
  $headers[] = "Content-Type: text/xml";
  
  $curl = curl_init($endpoint);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
  
  $response = curl_exec($curl);
  $data = simplexml_load_string($response) ;
  
  $AckResponse = $data-&gt;Ack ;
  
  $xml=simplexml_load_string($response) or die("Error: Could not get item");
  $itemvalueprice = (float)$data-&gt;Item-&gt;ConvertedCurrentPrice;
  $itemprice = $itemvalueprice * $profit;
  $price = round_up ($itemprice, 1);
  $paybutton = '&lt;form name="_xclick" action="https://www.paypal.com/us/cgi-bin/webscr" method="post"&gt;
  &lt;input type="hidden" name="cmd" value="_xclick"&gt;&lt;input type="hidden" name="business" value="my@paypal.com"&gt;
  &lt;input type="hidden" name="currency_code" value="USD"&gt;
  &lt;input type="hidden" name="item_name" value="' . htmlentities($data-&gt;Item-&gt;Title, ENT_QUOTES) . '"&gt;
  &lt;input type="hidden" name="amount" value="' . $price . '"&gt;&lt;input type="hidden" name="on0" value="IMEI"&gt;&lt;input type="text" name="os0" &gt;
  &lt;br /&gt;
  &lt;input type="image" src="ordernow.jpg" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt;
  &lt;/form&gt;' ;
  $endt = str_replace(".000Z", "", $data-&gt;Item-&gt;EndTime);
  $endtime = explode(T,$endt);
  $startt = str_replace(".000Z", "", $data-&gt;Item-&gt;StartTime);
  $starttime = explode(T,$startt);
  $oldtrans = array('P','D','T','H','M','S');
  $newtrans = array('&lt;span class="red"&gt; in &lt;/span&gt;','d, ','','h ','m ','s');
  $timeleft = str_replace($oldtrans,$newtrans,$data-&gt;Item-&gt;TimeLeft);
  
  
  echo '&lt;h2&gt;' . htmlentities($data-&gt;Item-&gt;Title, ENT_QUOTES) . '&lt;/h2&gt;
  &lt;span&gt;Price &lt;strong&gt;' . $price . '&lt;/strong&gt;$ &lt;/span&gt;
  &lt;span&gt;Sold &lt;strong&gt;' . $data-&gt;Item-&gt;QuantitySold . '&lt;/strong&gt; &lt;/span&gt;
  &lt;span&gt;Score &lt;strong&gt;' . $data-&gt;Item-&gt;Seller-&gt; PositiveFeedbackPercent . '&lt;/strong&gt;% &lt;/span&gt;
  &lt;span&gt;&lt;strong&gt;' . $data-&gt;Item-&gt;ListingStatus . '&lt;/strong&gt;&lt;/span&gt;
  &lt;span&gt;&lt;img src="' . $data-&gt;Item-&gt;GalleryURL . '" alt="' . htmlentities($data-&gt;Item-&gt;Title, ENT_QUOTES) . '" /&gt;&lt;/span&gt;
  &lt;span&gt;' . $paybutton . '&lt;/span&gt;&lt;span&gt;Expires ' . $endtime[0] . '' . $timeleft . '&lt;/span&gt;
  &lt;br /&gt;&lt;br /&gt;' ;
  }
  ?&gt;
  </code></pre>
  
  <p>My question is why does it show <code>ERROR</code>? If there is an <code>ERROR</code> why does it show all items most of the time? And even with <code>ERROR</code> it will always show the 2 first items in the array.</p>
  
  <p>Any idea how to solve this?</p>
  
  <p>Thank you for helping.</p>