while ($item = $ItemSelection->fetch_array(MYSQLI_ASSOC)) {
$itemNo = $item['ItemID'];
$date = $item['date'];
$SKU = $item['SKU'];
$startprice = $item['startprice'];
$lagerbestand = intval($item['fVerfuegbar']);
$startprice = $startprice * 2; // Startpreis
$handlingtime = 40; // Lieferzeit
if($item){
$x++;
echo "<p>". $x ." -- ". $itemNo ." ". $SKU ." ". $startprice ."</p>";
$siteid = 77;
$callname = "ReviseItem";
$endpoint = "https://api.ebay.com/ws/api.dll";
$api_dev_name = "";
$api_app_name = "";
$api_cert_name = "";
$headers = array(
'Content-Type:text/xml',
'X-EBAY-API-COMPATIBILITY-LEVEL: 963',
'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-CALL-NAME: '.$callname,
'X-EBAY-API-SITEID: '.$siteid
);
$body .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$body .= "<ReviseItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">";
$body .= "<RequesterCredentials><eBayAuthToken>".$auth_token."</eBayAuthToken></RequesterCredentials>";
$body .= "<DetailLevel>ReturnAll</DetailLevel>";
$body .= "<ErrorLanguage>en_US</ErrorLanguage>";
$body .= "<Item>";
$body .= "<ItemID>".$itemNo."</ItemID>";
//$body .= "<StartPrice>".$startprice."</StartPrice>";
$body .= "<DispatchTimeMax>".$handlingtime."</DispatchTimeMax>";
$body .= "</Item>";
$body .= "</ReviseItemRequest>";
$curl = curl_init();
curl_setopt_array($curl,
array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $endpoint,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => $headers
)
);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXmlElement($response);
$path = dirname(__FILE__);
$handle = fopen($path."/logs/ebay_setprice_".date("Y-m-d").".log", "a+");
$date = date("Y-m-d H:i");
$status = $xml->Ack;
$code = $xml->Errors->ErrorCode;
$shortmessage = $xml->Errors->ShortMessage;
$longmessage = $xml->Errors->LongMessage;
unset($curl);
unset($body);
unset($headers);
// Log Datei Eintrag
$itemLog = $itemNo."|".date("Y-m-d H:i:s")."|".$SKU."|".$xml->Ack."|".$xml->Errors->ShortMessage."|".$xml->Errors->LongMessage."\r\n";
fwrite($handle,$itemLog);
fclose($handle);
$xml = "";
$response = "";
} // end if
} // end while
$old_itemLog = $path."/logs/ebay_setprice_".date("Y-m-d",strtotime("-1 days")).".log";
if(file_exists($old_itemLog)){
exec("rm -f ".$old_itemLog);
}