我正在开发一个链接到Protx VSP Direct payment gateway的PHP应用程序。为了处理来自信用卡处理公司的"3D安全“请求,我需要将用户转发到不同的网站,模仿已发布的表单。我正在尝试使用cURL库,但似乎遇到了问题。我的代码如下:
<?php
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/');
// Perform a POST
curl_setopt($ch, CURLOPT_POST, 1);
// If not set, curl prints output to the browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
// Set the "form fields"
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$output = curl_exec($ch);
curl_close($ch);
?> 所有这些操作都是获取传递的URL的内容,而不是将用户转发到任何地方。我试着尽可能多地搜索和阅读,但找不到我错过了什么。有什么想法吗?如果可以避免,我不想创建一个自动提交自身的HTML表单。
感谢您的帮助:-)
发布于 2008-09-19 19:40:25
3D安全API不允许您在后台执行请求。您需要将用户转发到3D安全站点。使用javascript自动提交表单。以下是我们的提供商的建议:
<html>
<head>
<title>Processing your request...</title>
</head>
<body OnLoad="OnLoadEvent();">
<form name="downloadForm" action="<%=RedirURL%>" method="POST">
<noscript>
<br>
<br>
<div align="center">
<h1>Processing your 3-D Secure Transaction</h1>
<h2>JavaScript is currently disabled or is not supported by your browser.</h2><BR>
<h3>Please click Submit to continue the processing of your 3-D Secure transaction.</h3><BR>
<input type="submit" value="Submit">
</div>
</noscript>
<input type="hidden" name="PaReq" value="<%=PAREQ%>">
<input type="hidden" name="MD" value="<%=TransactionID%>">
<input type="hidden" name="TermUrl" value="<%=TermUrl%>">
</form>
<SCRIPT LANGUAGE="Javascript">
<!--
function OnLoadEvent() {
document.downloadForm.submit();
}
//-->
</SCRIPT>
</body>
</html>发布于 2008-09-19 19:42:32
我认为您对curl的作用感到有点困惑。它完全按照你解释的那样工作,它的行为有点像浏览器,它调用网站并返回帖子的内容。我不知道有什么方法可以真正重定向浏览器服务器端并表示一个帖子。我实际上会创建一个Javascript解决方案来做这样的事情。
发布于 2008-09-19 19:42:33
要在PHP中将用户重定向到另一个页面,您可以发送一个header("Location: http://example.com/newpage");。然而,不幸的是,对于您的程序重定向导致所有POST变量被删除(出于安全原因)。如果要使用户的浏览器将POST请求发送到不同的URL,则必须创建一个提交自身的表单。:(
https://stackoverflow.com/questions/104872
复制相似问题