Şimdi şöyle bi sorunum var...
sunucya aşağıdaki kodları bulunan dosya ile resimleri inidrmek istiyorum ama 800 kadar ürün resimi indikten sonra
500 Internal Server Error hatası veriyor bu sorunu nasıl çözebilirim?
Buna şunu nasıl yaparım.. Startindex: 1
finishindex:500
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
ini_set('max_execution_time', 0);
//$path = "/Users/sak/www/www/altay/";
//$xml = simplexml_load_file($path . "15001_33180_ALTAY.xml");
$xml = simplexml_load_file("15000_ALTAY.xml");
//print_r($xml);
foreach ($xml->urunler as $products) {
foreach ($products->urun as $urun) {
$resimler = (string)$urun->resim;
// if (!is_null($resim) || $resim<>"") {
if ($resimler) {
$pictures = explode("|", $resimler);
foreach ($pictures as $resim) {
//$image=file_get_contents("https://b2b.site.com/files/product/30999a72-24e7-423b-9cce-4894e326fefc.jpg");
$image = file_get_contents($resim);
$resimAd = explode("/", $resim);
$resimAdi = $resimAd[sizeof($resimAd) - 1];
//echo $resim;
echo $resimAdi;
file_put_contents("images/" . $resimAdi, $image);
}
}
}
}
?>
basitce verilen kodu php tarafında şu şekilde yorumlayabilirsin
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://www.domain.com/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 12000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"contenttype: application/json",
"ws_finishindex: << BİTİŞ INDEX >>",
"ws_pass: << ŞİFRE >>",
"ws_startindex: << BAŞLANGIÇ INDEX >>",
"ws_type: xml",
"ws_user: << KOD >>"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}