ya ur correct and im already looking in curl_multi_init(), but getting confused as der is also a form here…
lets take it one by one, for the first step
for single execution, i have the input for the html stored in $u
here is the code working
$location = 'abc';
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $location );
$post_array = array(
"rid" => $u,
"submit" => "submit"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
$response = curl_exec($ch);
now i want the same in parallel…
// already 3 inputs will be generated at one time for the HTML form, [will increase to 5 or 6 later]
// inputs are stored in php var $u[1], $u[2], $u[3]
i have this code, not yet executed but i am unable to decide where the output is stored, [as in the prev case its stored in $response]
$location = 'abc';
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
$ch = curl_init();
$ch1 = curl_init();
$ch2 = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $location );
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_VERBOSE, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch1, CURLOPT_POST, 1);
curl_setopt($ch1, CURLOPT_URL, $location );
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_VERBOSE, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_URL, $location );
$post_array1 = array(
"rid" => $u[1],
"submit" => "submit"
);
$post_array2 = array(
"rid" => $u[2],
"submit" => "submit"
);
$post_array3 = array(
"rid" => $u[3],
"submit" => "submit"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array1);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $post_array2);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $post_array3);
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch);
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);