0

我想 curl cookies cookie 文件已创建但为空,为什么?而agent_http_code值:404,为什么?谢谢。

$url ="https://example.com";
$xmlfile = '/home/*******/public_html/2.xml';
$cookie_file = '/home/******/public_html/cookie.txt';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('action-xmlagentxmlfile'=>'@' . $xmlfile));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
if (file_exists($cookie_file) && filesize($cookie_file) > 0) {
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
}
4

0 回答 0