服务器设置定时任务-携带数据请求接口 --- 2020-03-0
2020-04-24 本文已影响0人
一位先生_
1:设置定时器
2:定时器请求接口代码
代码块
$data_string = $list; //$list存放携带数据
$ch = curl_init('http://域名/Admin/Push/entry');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
public function entry()
{
$postData = file_get_contents('php://input');
$postData = json_decode($postData, true);
}