使用curl发布数据并更改页面网址

时间:2013-08-14 07:07:12

标签: url post curl

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

但我的问题是,当我将带有curl的数据发布到银行时,页面url don t change! I see bank s结果出现在我的服务器页面中!!!

我需要这个发布数据,就像在html页面重定向中发布数据一样,已经确定了网址!

$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 ); 

0 个答案:

没有答案