2

请帮助我,我遇到了一些麻烦。我想做的是将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,但我没有被重定向到我的网站!

4

2 回答 2

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");
于 2012-11-01T10:52:09.453 回答
0

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

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
于 2012-11-01T11:09:30.557 回答