请帮助我,我遇到了一些麻烦。 我想做的是将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被创建并显示但我没有被重定向到我的网站!
答案 0 :(得分: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");
答案 1 :(得分:0)
当您使用数组设置CURLOPT_POSTFIELDS时,请求将作为multipart / form-data发送,请尝试将该行更改为:
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));