2

Hi am using multi curl for the first time. seems endless and reach my PHP execution limit.i can see it hitsserver(http://samples.com/attraction1w1.1/ServiceMobile.php) and server also responding successfully but multi curl response not getting.tried in many ways. Please help me to what am doing wrong or anything i missed Is there a way to set a timeout for each handle to avoid an endless loop? What else I could do to fix this problem?

$data = Array
(
    [0] => Array
        (
            [apiFunctionName] => process
            [action] => GetAttractionList
            [mode] => TEST
            [cityId] => 1
            [countryId] => 1
            [postData] => 
            [currencyCode] => SGD
            [referenceId] => Z29idWRnZXRhaXJURVNUMzYzMTk=
            [securityToken] => 3b489903de0daf1267879757cabebe7e
            [hashKey] => 3b489903de0daf1267879757cabebe7e
            [access] => mobile
            [userName] => GBAB2C
            [code] => 1
            [apiName] => Globaltrix
            [returnType] => JSON
            [apiUrl]=>http://samples.com/attraction1w1.1/ServiceMobile.php 
        )

)
foreach ($data as $id => $d)
{
    $curly[$id] = curl_init();                       
    curl_setopt($curly[$id], CURLOPT_URL, $dataURL[$id]);
    curl_setopt($curly[$id], CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8")); 
    curl_setopt($curly[$id], CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curly[$id], CURLOPT_ENCODING, "gzip");
    if (is_array($d)) {
    curl_setopt($curly[$id], CURLOPT_POSTFIELDS, json_encode($data[$id]));
    } 
    if (!empty($options)) {
        curl_setopt_array($curly[$id], $options);
    }

    curl_multi_add_handle($attr, $curly[$id]);
}                                                                           
$running = null;
do {
    curl_multi_exec($attr, $running);
} while($running > 0);
foreach($curly as $id => $c) {
    $result[$id] = curl_multi_getcontent($c);
    curl_multi_remove_handle($attr, $c);
}
echo "<pre>";print_r($result);die;

0 Answers0