我在Google上搜索了此文件,但是所有链接都提到curl无法保存文件,但是就我而言,curl正确保存了文件,但内容仅是您所看到的:
"SHA256","89EC548C14582B2BDC7739BC0FA007","C:\WINDOWS\system32@Ap.png"
"SHA256","0B99B2576F1FA0689FF6E03462076C","C:\WINDOWS\system32@AudioTot"
"SHA256","F3B178AD338023AA3CBCB071CC0063","C:\WINDOWS\system32@biage.png"
"SHA256","383D8CBFCD078B3D661655A816676F","C:\WINDOWS\system32@edage.mui"
"89EC548C14582B2BDC7739BC0FA007",-2
"0B99B2576F1FA0689FF6E03462076C",-2
"0A57D7F60CDD9DB6F6F461BBC464FD",-1
"F3B178AD338023AA3CBCB071CC0063",-2
"7BCA060610F1A753A881593F967G47",-1
"383D8CBFCD078B3D661655A816676F",-2
我有这个网站在Xampp中运行,并且一切正常。 当我迁移到IIS时,唯一的问题是curl无法将cookie的内容保存在文件中。
我不知道我做错了什么。
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
--- no cookie contents here ---- only header ----
为确保我收到标题cookie,我添加了此
//Initiate cURL.
$ch = curl_init($url);
//The JSON data.
$jsonData = array(
'login' => $login,
'password' => $password,
'idioma' => $idioma,
'server' => $server,
'sistema' => $sistema
);
//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);
//curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:\cookies\cookieFile.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "C:\cookies\cookieFile.txt");
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
//Execute the request
$data=curl_exec($ch);
if ($data) {
//var_dump($data);
}else
{
echo "Não foi possível abrir o Sistema no Serviço Eticadata";
}
curl_close($ch);
这是在我var_dump Data时的响应中
curl_setopt($ch, CURLOPT_HEADER, 1);
但是查看C:\ cookies \ cookieFile.txt,其内容为:
HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/10.0 Set-Cookie: ASP.NET_SessionId=ke2s2lf0mkdbqlcfbghrqgg5; path=/; HttpOnly X-AspNet-Version: 4.0.30319 Set-Cookie: .eti_ASPXAUTH=5DE2B541B7CCE00C4356B3D0D9CA0D82C9819A5EB9E915924913DCB3B7FB511D6A27026CECC878FD295B1E8F262B53A8A9F9946318BEEE4C0487ED9F9B64547451EDC9D2C4458A8FEECFEABBD24EE0CF2DD2FCD80B4C3931622309DB443E35066A71B8C01A160F4DDA5FE8594E4C7DD6E62B2D55EB25FCCC9C1C7F304F3285E0; path=/; HttpOnly Set-Cookie: eti_sessionInfo=YwBzAHcAcwBxAGwAXABjAG8AbQBwAHUAcwCnAFMAaQBzAHQAZQBtAGEAQwBTAFcApwBDAFMAVwCnAEUAeAAgADIAMAAxADkApwAxAKcAUABUAC0AUABUAA==; path=/ X-Powered-By: ASP.NET Date: Wed, 12 Jun 2019 15:27:01 GMT Content-Length: 56350
里面没有cookie。
编辑
这里有卷曲的详细信息
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.