|
|
|
@ -381,4 +381,60 @@ function get_IA_Response($iaUrl,$postParams){
|
|
|
|
|
'response' => $output,
|
|
|
|
|
'responseArr' => $arr
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function get_multi_IAS_Responses($iasUrls, $postParams){
|
|
|
|
|
//same as the previous function
|
|
|
|
|
// but more than one bot requested parallely
|
|
|
|
|
|
|
|
|
|
$cmh = curl_multi_init();
|
|
|
|
|
for ($i = 0; $i < count($iasUrls); $i++){
|
|
|
|
|
$data_string = json_encode($postParams[$i]);
|
|
|
|
|
|
|
|
|
|
$ch[$i] = curl_init($iaUrl);
|
|
|
|
|
curl_setopt($ch[$i], CURLOPT_CUSTOMREQUEST, "POST");
|
|
|
|
|
curl_setopt($ch[$i], CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
|
curl_setopt($ch[$i], CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
|
curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $data_string);
|
|
|
|
|
curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
curl_setopt($ch[$i], CURLOPT_HTTPHEADER, array(
|
|
|
|
|
'Content-Type: application/json',
|
|
|
|
|
'Content-Length: ' . strlen($data_string))
|
|
|
|
|
);
|
|
|
|
|
curl_multi_add_handle($cmh,$ch[$i]);
|
|
|
|
|
}
|
|
|
|
|
//send the requests
|
|
|
|
|
do {
|
|
|
|
|
$returnVal = curl_multi_exec($cmh, $runningHandles);
|
|
|
|
|
} while ($returnVal == CURLM_CALL_MULTI_PERFORM);
|
|
|
|
|
// Loop and continue processing the request
|
|
|
|
|
while ($runningHandles && $returnVal== CURLM_OK) {
|
|
|
|
|
// Wait forever for network
|
|
|
|
|
$numberReady = curl_multi_select($cmh);
|
|
|
|
|
if ($numberReady != -1) {
|
|
|
|
|
// Pull in any new data, or at least handle timeouts
|
|
|
|
|
do {
|
|
|
|
|
$returnVal = curl_multi_exec($cmh, $runningHandles);
|
|
|
|
|
} while ($returnVal == CURLM_CALL_MULTI_PERFORM);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Get results
|
|
|
|
|
for ($i = 0; $i < count($iasUrls); $i++)
|
|
|
|
|
{
|
|
|
|
|
// Check for errors
|
|
|
|
|
$curlError = curl_error($ch[$i]);
|
|
|
|
|
if($curlError == "") {
|
|
|
|
|
$res[$i] = curl_multi_getcontent($ch[$i]);
|
|
|
|
|
} else {
|
|
|
|
|
$res[$i] = false
|
|
|
|
|
}
|
|
|
|
|
//close
|
|
|
|
|
curl_multi_remove_handle($cmh, $ch[$i]);
|
|
|
|
|
curl_close($ch[$i]);
|
|
|
|
|
}
|
|
|
|
|
// Clean up the curl_multi handle
|
|
|
|
|
curl_multi_close($mh);
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|