php curl可以设置推迟3秒再执行吗?
<?php$curl = curl_init();curl_setopt_array($curl, array( CURLOPT_URL => 'http://www.baidu.com/', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Connection: <Connection>', 'Accept: <Accept>', 'User-Agent: <User-Agent>', 'Sec-Fetch-Site: <Sec-Fetch-Site>', 'Sec-Fetch-Mode: <Sec-Fetch-Mode>', 'Sec-Fetch-Dest: <Sec-Fetch-Dest>', 'Referer: <Referer>', 'Accept-Language: <Accept-Language>', 'Cookie: <Cookie>' ),));$response = curl_exec($curl);curl_close($curl);echo $response;如题,因为我调用个api就必须要执行2次,但执行1次下一次要间隔3秒后才可以执行2,不然后会提示:操作失败,操作过于频繁,请过3秒后再试。
有什么方案吗? 如果是频繁执行的话建议队列,不频繁就简单sleep函数:lol 补教程: https://www.runoob.com/php/func-misc-sleep.html 睡眠函数 sleep 大/法好 可行,谢谢 可行,谢谢
页:
[1]