PHP ile cURL yardım

0 Cevap php

Ben cURL ile oynuyorum, ve ben işe alma konusunda sorun yaşıyorum. Ben Results.txt yılında yayınlanan verileri görebilirsiniz böylece cURL komut bu form üzerinde veri göndermek istiyorum. İşte benim form script ve sonra benim cURL komut sonra. Ben buraya göndermeden önce $ url değişti.

Edit: Sorun bu verileri gönderme değil, olduğunu. Ben cURL senaryoyu koştu ve sonrası verileri bulmak için Results.txt kontrol "ÇALIŞIR" ve devamsızlığı. Herhangi bir fark yaparsa Ayrıca, ben DreamHost kullanıyorum.

GÜNCELLEME: Ben Tamamdır! Komik bir şey. Ben şeklinde yerine POST işler sayfa sayfa hedeflenmiş.

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"/>
    <title>Test</title>
  </head>

  <body>
    <form method="POST" name="TestForm" action="write.php">
      <p />
      Input anything: <input type="text" name="anything" value="Default"/> <br />
      <input type="submit" value="OK" name="submit" />
    </form>
  </body>
</html>

write.php code source

    $stringData1 = $_POST["anything"];
    $myFile = "results.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = "Bobby Bopper\n";
    fwrite($fh, $stringData);
    fwrite($fh, $stringData1);
    fclose($fh);


?>

Benim cURL script kodunu kaynağı:

<?php

$url = "http://www.domain.com/submit/index.php";


$useragent="YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; http://search.yahoo.com/)";

$ch = curl_init();


curl_setopt($ch, CURLOPT_USERAGENT, $useragent);


curl_setopt($ch, CURLOPT_URL, $url);


curl_setopt($ch, CURLOPT_POST, 1);


curl_setopt($ch, CURLOPT_POSTFIELDS, "anything=WORKS");


$result= curl_exec ($ch);
curl_close ($ch); 


print "<br/> test" . $result;

?>

0 Cevap