1

curl を使用して銀行にログオンしようとしています。Cookie(JavaScriptによって設定される)までは、すべてうまく機能します。これは私が送信しようとしているフォームです (資格情報は偽物です):

<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>

次の PHP / CURL コードを使用:

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;

「お使いのブラウザは Cookie をサポートしていません」という応答が表示されます。これを回避するためのきちんとした解決策はありますか?

4

1 に答える 1

0

私のアドバイスは、Fiddler2 のようなものを使用することです: http://www.fiddler2.com/fiddler2/

銀行に通常どおりログインすると、Fiddler がすべてをログに記録します (https デコードを有効にする必要があります。そうしないと、http トラフィックのみが表示されます)

これらのログから、未加工のヘッダー情報と未加工の Cookie の内容を確認できます。次に、この情報を使用して、cURL でログインを複製します。

于 2012-11-02T14:32:29.870 に答える