如何用alax和curl复制这个数据帖子?
...
data: {
search: JSON.stringify({
daterange : "custom",
daterangecustom : {
start : "2013-03-01T23:59:59",
end : "2018-03-01T23:59:59"
}
}),
limit: 50
},
...
我不需要curl的整个代码,但只需要$params
值:
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
我一直试图让这项工作暂时没有成功。非常感谢任何有解决方案的人!!
答案 0 :(得分:1)
不知道多少,我认为这就是你要找的东西:
$data = array(
'search' => array(
'daterange' => 'custom',
'daterangecustom' => array(
'start' => '2013-03-01T23:59:59',
'end' => '2018-03-01T23:59:59',
),
),
'limit' => 50,
);
$headers = array(
'Content-type: application/json',
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
请求将如下所示:
POST /url HTTP/1.1
Host: host
Accept: */*
Content-type: application/json
Content-Length: 122
{"search":{"daterange":"custom","daterangecustom":{"start":"2013-03-01T23:59:59","end":"2018-03-01T23:59:59"}},"limit":50}