Curl_exec çökmesini olmadan CURLOPT_NOBODY kurulamıyor

0 Cevap php

Ben bu bir hata için tüm gün kendimi öldürüyorum oldum. Ben bu konuda olası yardım takdir ediyorum ne kadar yeterli söyleyemem.

Temelde, ben çok basit bir komut dosyası var. Bu, bir web sitesi haline günlükleri bir görüntü türü olup olmadığını görmek için bir dosyanın başlık bakar ve sonra onu indirir. Bu, daha sonra üç kez tekrar eder.

Burada sorun ben-hayır-hataları ile tüm komut çökmesini curl_exec olmadan CURLOPT_NOBODY ayarlanamaz olmasıdır. (Ben bile arayabilir veya bir curl_error alınamıyor!) O bana sahte CURLOPT_NOBODY, gerçek CURLOPT_NOBODY, gitmek için imkansız olduğunu görünüyor. Aşağıdaki döngü bir kez çalışır ve daha sonra ölür ().

Ne muhtemelen bu hata neden olabilir?

İşte betik:

// Log into the Website
curl_setopt($ch, CURLOPT_URL, 'http://myexample.com/login');
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12");
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_exec($ch);

// Begin the Loop for Finding Images
for($i = 0; $i < 3; $i++) {
    curl_setopt($ch, CURLOPT_URL, 'http://myexample.com/file.php?id=' . $i);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    $output = curl_exec($ch) or die('WHY DOES THIS DIE!!!');
    $curl_info = curl_getinfo($ch);
    echo '<br/>' . $output;

    // (Normally checks for content type here) Download the File
    curl_setopt($ch, CURLOPT_URL, 'http://myexample.com/file.php?id=' . $i);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_NOBODY, false);
    $filename = 'downloads/test-' . $i . '.jpg';
    $fp = fopen($filename, 'w');
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_exec($ch);
    fclose($fp);
}

I'm running apache 2.2 and PHP version 5.2.13. Thanks for any help- I can't tell you how much I'd appreciate it. I'm completely stuck here. :(

0 Cevap