当curl_error为true并且如果仍然失败,请在错误日志中输入时,我想保持此代码循环(两次/三次)。在获取错误和登录时重复CURL代码php
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$response = curl_exec($ch);
/* if there is an error show error */
if (curl_error($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) {
$success = false;
return view('frontend.user.rss', compact('project_detail_all','active_project_detail','rss_detail','success'));
}
curl_close($ch);
请给出您的建议,谢谢。
你想运行此卷曲的2-3倍?你可以使用PHP的循环https://www.w3schools.com/php/php_looping_for.asp –
我知道循环在PHP中,但我的问题是“循环时发生错误,如果仍然失败陷入错误文件” –