1

我有一个购物网站,我必须将用户名和密码以及其他一些数据发送到银行,所以我使用 curl 来发布数据。因为它应该是安全的。

但我的问题是当我使用 curl 向银行发布数据时,页面 url 不会t change! I see bank导致我的服务器页面!!!

我需要这个发布数据与在 html 页面重定向中发布数据相同的 url 已经确定!

$data = array(
        "MID" => "0113-19",
        "RedirectURL" => $SERVER . "/shop/profile.php",
        "Amount" => $sum,
        "ResNum" => $ResNum,
        "username" => "xxxx",
        "password" => "1234");
        //traverse array and prepare data for posting (key1=value1)
        foreach ( $data as $key => $value) {
            $data[] = $key . '=' . urlencode($value);
        }



$post_string = implode ('&', $data);
    $res = array();
    $options = array( 
        CURLOPT_RETURNTRANSFER => true,     // return web page 
        CURLOPT_POST => true,     // return web page 
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects 
        CURLOPT_AUTOREFERER    => false,     // set referer on redirect 
        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect 
        CURLOPT_TIMEOUT        => 120,      // timeout on response 
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects 
        CURLOPT_POSTFIELDS      => $post_string,       // stop after 10 redirects 
        CURLOPT_SSL_VERIFYPEER      => false ,     // stop after 10 redirects 
        CURLOPT_COOKIEJAR      => "cookie.txt" ,     // stop after 10 redirects 
        CURLOPT_COOKIEFILE      => "cookie.txt" ,     // stop after 10 redirects 
        CURLOPT_SSL_VERIFYPEER      => false ,     // stop after 10 redirects 

        CURLOPT_USERAGENT      => "Mozilla/5.0 (Windows; U;
    Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"      // stop after 10 redirects 
        ); 

    //////////////////////
    $ch      = curl_init( $url ); 
    curl_setopt_array( $ch, $options ); 
    $content = curl_exec( $ch ); 
    $err     = curl_errno( $ch ); 
    $errmsg  = curl_error( $ch ); 
    $header  = curl_getinfo( $ch ); 
    curl_close( $ch ); 
4

0 回答 0