cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Simultaneous curl posts on the same URL [without curl_multi]

From: Baragan Andrei <an_dlei_at_yahoo.com>
Date: Tue, 27 Sep 2005 09:38:46 -0700 (PDT)

Hi,
The problem is that i want to run multiple curls at once, on the same URL but with different post parameters.
I have a main script in which i exec() a script curl.php with the right parameters. In curl.php i set the url, the parameters for the post, i curl_exec and get the results. The problem is that only the last executed script gives me the right results (it posts the data), the previous executed ones do fill the html forms correctly but they don't submit the data.
I think that curl reuses connections, and maybe that is the problem. I have tried the following setopts with FORBID_REUSE etc .. but still no result. I even tried variable variables like $$ but nothing. Here is the code in curl.php
 
ini_set('magic_quotes_gpc','off');
ini_set('register_globals','off');
ini_set('register_argc_argv','off');
 $email = $_SERVER['argv'][1];
$ch = "ch" . $email;
   $url = 'http://xxx';
   $params = "email=$email";
   $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
   $$ch = curl_init();
   curl_setopt($$ch, CURLOPT_FORBID_REUSE,1);
   curl_setopt($$ch, CURLOPT_FRESH_CONNECT,1);
   curl_setopt($$ch, CURLOPT_POST,1);
   curl_setopt($$ch, CURLOPT_POSTFIELDS,$params);
   curl_setopt($$ch, CURLOPT_URL,$url);
   curl_setopt($$ch, CURLOPT_SSL_VERIFYHOST,2);
   curl_setopt($$ch, CURLOPT_USERAGENT,$user_agent);
   curl_setopt($$ch, CURLOPT_RETURNTRANSFER,1);
   curl_setopt($$ch, CURLOPT_SSL_VERIFYPEER,FALSE);
   curl_setopt($$ch, CURLOPT_MAXCONNECTS,1);
   curl_setopt ($$ch, CURLOPT_FOLLOWLOCATION,1);
   $result=curl_exec ($$ch);
   $search = "search string";
   if(strpos($result, $search) !== false) {
 //write a file
   }
   curl_close ($$ch);
   unset($$ch);
 ?>
What setopt should i use so that curl would not reuse the connection, or just how do i get the right results every time ?
If anyone has an idea, no matter how wild, please respond.
PS: I cannot use php5's curl_multi_* functions. Thank you.

                
---------------------------------
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-09-27