Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/462.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何登录到使用带有Curl的JavaCookie的https?_Php_Javascript_Curl_Autologin - Fatal编程技术网

Php 如何登录到使用带有Curl的JavaCookie的https?

Php 如何登录到使用带有Curl的JavaCookie的https?,php,javascript,curl,autologin,Php,Javascript,Curl,Autologin,我正在尝试使用curl登录我的银行。在涉及到cookie(由javascript设置)之前,一切都很好。这是我试图发送的表单(凭据是假的): 我得到的回答是“您的浏览器不支持cookies”。有什么好办法可以解决这个问题吗?我的建议是使用类似Fiddler2的东西: 正常登录您的银行,Fiddler将记录所有内容(您需要启用https解码,否则它只会看到您的http流量) 从这些日志中,您可以看到原始标头信息和原始cookie内容。然后使用此信息在cURL中复制登录 <form met

我正在尝试使用curl登录我的银行。在涉及到cookie(由javascript设置)之前,一切都很好。这是我试图发送的表单(凭据是假的):


我得到的回答是“您的浏览器不支持cookies”。有什么好办法可以解决这个问题吗?

我的建议是使用类似Fiddler2的东西:

正常登录您的银行,Fiddler将记录所有内容(您需要启用https解码,否则它只会看到您的http流量)

从这些日志中,您可以看到原始标头信息和原始cookie内容。然后使用此信息在cURL中复制登录

<form  method="post" action="https://www.icabanken.se/Secure/Login/LoginVerify.aspx">
    <input type="hidden" name="pnr" value="8502191714" />
    <input type="hidden" name="JSEnabled" value="1" />
    <input type="hidden" name="OBAS" value="" />
    <input type="hidden" name="refurl" value="" />
    <input type="hidden" name="refurlrequiressigning" value="False" />
    <input type="password" class="typetext" name="Password" id="PasswordSimple" maxlength="4" value="1111" />
    <input class="button-image button-small" type="submit" id="LoginSimplifiedButton" value="Logga in" />
</form>
enter codssde here

$post_data['pnr'] = '8502191714';
$post_data['password'] = '1111';
$post_data['JSEnabled'] = '1';
$post_data['OBAS'] ='';
$post_data['refurlrequiressigning'] = '';
$post_data['refurl'] = '';  


foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
}

$post_array = implode ('&', $post_items);

$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_CERTINFO, 1);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 1000000);

//COOKIES
$Cookiefile='C:\wamp\www\Project1\gcookies.txt';          
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookiefile);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $Cookiefile);


curl_setopt($ch, CURLOPT_HEADER, 1);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);

curl_setopt($ch, CURLOPT_URL,'https://www.icabanken.se/Secure/Login/LoginVerify.aspx');
$data = curl_exec($ch);


echo $data;