PHP cURL关注帖子位置

时间:2014-08-04 18:09:05

标签: php forms curl

我正在使用付款表单服务,我需要设置一个带有给定名称的隐藏字段的表单。提交后,我的表单会发布到付款服务,该服务会根据表单发布数据将我重定向到他们的表单。

由于我正在加密我的服务密码存在问题,我试图用PHP脚本而不是curl来做这件事。在我的请求之后,我没有转发到表单,它只是在我的php页面上作为空白页

$username = "[removed]";
$password = "[removed]";

$url = '[removed]';
$fields = array(
    'Mode' => urlencode('PaymentForm'),
    'Login' => urlencode($username),
    'Password' => urlencode($password),
    'ReceiptUrl' => urlencode("[removed]"),
    'Description' => urlencode($_POST['Description']),
    'TotalAmt' => urlencode($_POST['TotalAmt']),
);

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

//execute post
$result = curl_exec($ch); 
curl_close($ch);

0 个答案:

没有答案