• 06-02-2019, 18:02:57
    #1
    merhaba;

    çalıştığım bir firma bana xml den veri çekmem için kendi ip adresimi tanımladığı ve xml dosyası vermedi ama xml olarak ürün bilgilerini çekmem için bi kod paylaştı.

    şimdi sorum şu?
    Benim e-ticaret sitemin yayınlandığı sunucu linux tabanlı verilen kodlar asp.net

    Bu ürünleri kendi oluşturduğum bir veri tabanına eklemem gerekiyor sonra düzenleyip siteye aktarmam gerekiyor. Bu işlemi yapmam için bana biraz yardım gerekiyor

    Verilen xml için kod aşağıda yazılı buna göre veriyi çekmeliyim ve aynı veriyi veritabanına belli aralıkta çalıştırılıp yeni stok ve stok durumu ve ayrıca fiyat güncellemesi enson olarakta ürünlere ait ürünleri sunucuya kaydetmek.

    Örnek kodlar aşağıda paylaşılmıştır.
    
    C# örnek:
    
    private string WebRequest()
    {
    try
    {
    var webRequest = System.Net.WebRequest.Create("<< URL >>");
    if (webRequest != null)
    {
    webRequest.Method = "GET";
    webRequest.Timeout = 12000;
    webRequest.ContentType = "application/json";
    webRequest.Headers.Add("ws_user", "<< KOD >>");
    webRequest.Headers.Add("ws_pass", "<< ŞİFRE >>");
    webRequest.Headers.Add("ws_type", "xml"); // xml veya json
    webRequest.Headers.Add("ws_startIndex", "<< BAŞLANGIÇ INDEX >>");
    webRequest.Headers.Add("ws_finishIndex", "<< BİTİŞ INDEX >>");
    
    
    using (System.IO.Stream s = webRequest.GetResponse().GetResponseStream())
    {
    using (System.IO.StreamReader sr = new System.IO.StreamReader(s))
    {
    return sr.ReadToEnd();
    }
    
    }
    }
    else
    {
    return string.Empty;
    }
    }
    catch (Exception ex)
    {
    return ex.Message;
    }
    }
  • 06-02-2019, 19:30:48
    #2
    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;
    }
  • 08-02-2019, 11:08:05
    #3
    onekey15 adlı üyeden alıntı: mesajı görüntüle
    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;
    }
    Üstadım çok teşekkür ederim. Chrome la o işi kolay hallettim.. zahmetsiz.
  • 28-02-2019, 16:24:03
    #4
    Şimdi şöyle bi sorun var.
    XML indirdim bilgisayarıma.
    XML verilerini CSV olarak siteye ekledim,
    Ortada bir sorun var.
    XML de verilen resim yolundaki resimleri kendi bilgisayarıma indirmem gerekiyor.
    Daha sonra bu resimleri sunucuya atacağım, attığım ürün resimlerini stok koduna göre hazırlanmış bir csv dosyasıyla veritabanına atmam gerekiyor.

    Bu resimleri sunucuya veya kendi pc me indirme yada çekme işlemini nasıl yaparım.
  • 03-03-2019, 16:18:39
    #5
    Ş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);
                }
            }
        }
    }
    
    ?>
    onekey15 adlı üyeden alıntı: mesajı görüntüle
    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;
    }