I now have a set of data, which is then requested through the concurrency of curl, but I need to know exactly which piece of data has gone wrong in the past; can this curl concurrency know the order of requests?
for example, I now have a set of data:
$test = [
[
abc: 1123
],
[
abc: 3333
],
[
abc: 444
]
];
when I request these three pieces of data concurrently, I want to know which abc has the wrong value. How to mark this order?
I have printed all kinds of return values. I don"t see any regularity. Do any friends know?
sample code is as follows:
$k = 0;
$query = "{"0":{"extension_number":"101","password":"101"},"1":{"extension_number":"102","password":"102"},"2":{"extension_number":"103","password":"103"},"3":{"extension_number":"104","password":"104"},"4":{"extension_number":"105","password":"105"},"5":{"extension_number":"106","password":"106"},"6":{"extension_number":"107","password":"107"},"7":{"extension_number":"108","password":"108"},"8":{"extension_number":"109","password":"109"},"9":{"extension_number":"110","password":"110"},"access_token":"3371AFB69D4248FDACC742C556916B87"}";
$query = json_decode($query, 1);
foreach ($strarr as $key=>$value)
{
//10
for ($i=0; $i<10; $iPP)
{
$value[$i]["access_token"] = "F11A7791C2684042BBF62C38AA01D428";
$ch[$k] = curl_init();
//url
curl_setopt($ch[$k], CURLOPT_URL, $url);
//
curl_setopt($ch[$k], CURLOPT_HEADER, 1);
//
curl_setopt($ch[$k], CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch[$k], CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch[$k], CURLOPT_SSL_VERIFYHOST, FALSE);
//post
curl_setopt($ch[$k], CURLOPT_POST, 1);
curl_setopt($ch[$k], CURLOPT_POSTFIELDS, json_encode($value[$i]));
curl_multi_add_handle($mh,$ch[$k]);
$kPP;
};
}
$active = null;
//
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);
}
}
//
foreach ($ch as $n=>$m)
{
$content=curl_multi_getcontent($m);
file_put_contents("hellow.php", $content."\r\n", FILE_APPEND);
curl_close($m);
curl_multi_remove_handle($mh, $m);
}
curl_multi_close($mh);
when I concurrently request, if any request fails, I need to know exactly which data request failed,
because I need to record the extension_number value of this failed record