do { $notify_time = time(); $last_notify_time = time(); $resultPartnerNotify = getHttpResponsePOST($notifyUrlPartner, $paramsPostPartner); //商户未返回success 会等待三秒然后接着发送请求。做到有相应之后,就处理后面逻辑,如果三次,九秒之后,还是没有请求成功,就提示失败 $resultPartnerNotify = strtolower(trim($resultPartnerNotify)); if ($resultPartnerNotify != 'success') { sleep($notifyTimes * 3); $notifyTimes++; } else { $notify_result = ORDER_NOTIFY_STATUS_SUCCESS; break; } } while ($notifyTimes <= 10); if (!function_exists('getHttpResponsePOST')) { function getHttpResponsePOST($url, $param) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_TIMEOUT, 60); // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //SSL证书认证 curl_setopt($curl, CURLOPT_HEADER, 0); // 过滤HTTP头 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 显示输出结果 curl_setopt($curl, CURLOPT_POST, true); // post传输数据 curl_setopt($curl, CURLOPT_POSTFIELDS, $param); // post传输数据 curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json;charset=UTF-8;")); $responseText = curl_exec($curl); $curl_errno = curl_errno($curl); $curl_error = curl_error($curl); curl_close($curl); if ($curl_errno > 0) { return '{"f":"0","m":"' . $curl_error . '"}'; } else { return $responseText; } } }
标签:return,notifyTimes,接口,查询,else,notify,time,php,resultPartnerNotify From: https://www.cnblogs.com/kevin-yang123/p/17012332.html