DEM
DEM

Reputation: 333

execute 2 cURL functions concurrently and randomly

I was wondering if it was possible to concurrently execute two post_to_url functions randomly at the same time -- the post_to_url function is a cURL request and $data are variables from a form. I have tried to rewrite the post_to_url function with curl_multi handle but it did not work. thanks for the help - much appreciated.

$urls = array(
   "http://examplesite1.com/cgi-bin/maxuseradmin.cgi",
   "http://examplesite2?fid=6646588e54",
   "http://examplesite1?fid=2fb44e3888"
);

$data = array(
    $data2,
    $data3,
    $data4
);
$x = rand(0,2);
post_to_url($urls[x], $data[x]);
post_to_url($urls[x], $data[x]);

Upvotes: 0

Views: 194

Answers (1)

Hanky Panky
Hanky Panky

Reputation: 46900

Try this Class

http://peecfw.googlecode.com/svn/trunk/Application/com/loadable/curl/CURL_thread.php

You can call it like this

$cURL = new CURL();
$cURL->addSession("https://www.example.com/?data=test");
$cURL->addSession("https://www.example2.com/?data=test");
$responses = $cURL->exec();  //This array will contain all responses
$cURL->clear();

Upvotes: 1

Related Questions