$weekNum = date('w',strtotime($date));
$weekarray = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
$xingqi = $weekarray[$weekNum];
将H:i:s格式的日期转化为周
function curl_post($url, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$url = "";
$auth =password_hash($md5,PASSWORD_DEFAULT);
$res = curl_post($url,array('auth'=>$auth));
访问api
业务实现:
对于一个存在相当耗时的任务的接口,例如删除所有用户信息(笑),如果直接实现会导致连接超时。由于PHP本身不支持异步,最简单的实现方式是:
- 在接口访问时将耗时任务列入队列/数据库
- 利用Corntab定时运行任务,取出要运行的任务并完成。
|