【问题标题】:Getting SESSION_ID from skrill server从 skrill 服务器获取 SESSION_ID
【发布时间】:2012-11-01 10:23:42
【问题描述】:

请帮帮我,我遇到了一些麻烦。 我想做的是将moneybooker 集成到我的网站中。 我研究了 2.3.2 主题中的“商家集成手册 6.17 版”,我必须通过邮寄支付参数来创建和获取 SESSION_ID 表单 skrill 服务器并获取 SESSION_ID,此会话将保存我的交易信息,如金额和我的帐户。

通过使用以下代码,我无法从他们的服务器检索 SESSION_ID。

$url = "https:www.moneybookers.com/app/payment.pl";

$post_data = array (  
        "prepare_only" => 1,  
        "amount" => 10,
        "currency" => 'USD',
        "detail1_description" => "Description",
        "detail1_text" => "Text",
        "pay_to_email" => "****my**accoutn@yahoo.com" 
    );  


$head = get_web_page($url, $post_data);
echo "<pre>";
print_r($head);
echo "</pre>";



function get_web_page( $url, $post_data )
{
    $options = array(
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_USERAGENT      => "spider", // who am i
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
        CURLOPT_TIMEOUT        => 120,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    );

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     //we are doing a POST request  
    curl_setopt($ch, CURLOPT_POST, 1);  
     //adding the post variables to the request  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
    return $header;
}

以上代码适用于其他网站,但不适用于 Moneybooker。 但是当我提交简单的 html 表单时,会创建并显示会话 ID,但我没有被重定向到我的网站!

【问题讨论】:

    标签: php session curl payment-gateway


    【解决方案1】:

    尝试添加 cookie 支持

    $fh = fopen("cookies.txt", "a+") or die("Can't open file!");
    fclose($fh);
    
    $ch = curl_init();
    
    
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
    

    【讨论】:

      【解决方案2】:

      当您使用数组设置CURLOPT_POSTFIELDS 时,请求将作为 multipart/form-data 发送,请尝试将该行更改为:

      curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
      

      【讨论】:

        猜你喜欢
        • 2012-01-20
        • 2014-07-16
        • 2012-05-03
        • 1970-01-01
        • 2022-01-23
        • 1970-01-01
        • 2012-11-28
        • 1970-01-01
        • 2016-11-14
        相关资源
        最近更新 更多