php - when connection times out using curl or get_file_contents to an API it kills my script -
when connection timesout when using curl or get_file_contents because of network error or remote server doesn't respond reason kills script.
i making these remote calls in loop , if 1 fails kills script.
what best way handle if specific post fails, goes on next in loop instead of script dying?
first set parameter curl timeout limit:
curl_setopt($ch, curlopt_timeout, 1800);
the result of curl_exec()
call show if request successful or not:
for(/* */) { $ch = curl_init(); //... $result = curl_exec($ch); if (!$result) { continue; // use jump next loop } // code not executed if request failed }
Comments
Post a Comment