同时随机执行2个cURL函数


execute 2 cURL functions concurrently and randomly

我想知道是否可以同时随机执行两个post_to_url函数——post_to_url函数是一个cURL请求,$data是表单中的变量。我试图用cURL_multi-handle重写post_to_rl函数,但它不起作用。谢谢你的帮助,非常感谢。

$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]);

尝试此类

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

你可以这样称呼它

$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();