关于 第三方接口支付的时候 采用post提交的方式,有两种 一种是通过 curl来进行,一种是通过js当页面加载完后跳转
2015-01-26 09:18
811 查看
这是第一种。通过javascript页面加载完后,对表单采用 post方式提交给 第三方接口-----
echo <<<_END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>正在转入支付页面......</title>
</head>
<body onLoad="javascript:document.E_FORM.submit()">
<p>正在转入支付页面.....</p>
<form method="post" name="E_FORM" action="https://Pay3.chinabank.com.cn/PayGate?encoding=UTF-8">
<input type="hidden" name="v_mid" value="$v_mid">
<input type="hidden" name="v_oid" value="$v_oid">
<input type="hidden" name="v_amount" value="$v_amount">
<input type="hidden" name="v_moneytype" value="$v_moneytype">
<input type="hidden" name="v_url" value="$v_url">
<input type="hidden" name="v_md5info" value="$v_md5info">
<input type="hidden" name="remark2" value="$remark2">
<input type="hidden" name="remark1" value="$remark1">
</form>
</body>
</html>
_END;
第二种传输方式是采用--curl post 来进行数据传输给服务器
<?php
$uri = "http://tanteng.duapp.com/test.php";
// 参数数组
$data = array (
'name' => 'tanteng'
// 'password' => 'password'
);
$ch = curl_init ();
// print_r($ch);
curl_setopt ( $ch, CURLOPT_URL, $uri );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
$return = curl_exec ( $ch );
curl_close ( $ch );
print_r($return);
接受php页面远程服务器:
<?php
if(isset($_POST['name'])){
if(!empty($_POST['name'])){
echo '您好,',$_POST['name'].'!';
}
}
?>
echo <<<_END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>正在转入支付页面......</title>
</head>
<body onLoad="javascript:document.E_FORM.submit()">
<p>正在转入支付页面.....</p>
<form method="post" name="E_FORM" action="https://Pay3.chinabank.com.cn/PayGate?encoding=UTF-8">
<input type="hidden" name="v_mid" value="$v_mid">
<input type="hidden" name="v_oid" value="$v_oid">
<input type="hidden" name="v_amount" value="$v_amount">
<input type="hidden" name="v_moneytype" value="$v_moneytype">
<input type="hidden" name="v_url" value="$v_url">
<input type="hidden" name="v_md5info" value="$v_md5info">
<input type="hidden" name="remark2" value="$remark2">
<input type="hidden" name="remark1" value="$remark1">
</form>
</body>
</html>
_END;
第二种传输方式是采用--curl post 来进行数据传输给服务器
<?php
$uri = "http://tanteng.duapp.com/test.php";
// 参数数组
$data = array (
'name' => 'tanteng'
// 'password' => 'password'
);
$ch = curl_init ();
// print_r($ch);
curl_setopt ( $ch, CURLOPT_URL, $uri );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
$return = curl_exec ( $ch );
curl_close ( $ch );
print_r($return);
接受php页面远程服务器:
<?php
if(isset($_POST['name'])){
if(!empty($_POST['name'])){
echo '您好,',$_POST['name'].'!';
}
}
?>
相关文章推荐
- 关于highcharts图表导出中文乱码以及采用post提交产生页面跳转问题
- js 进行post方式页面跳转
- 程序使用 HTTP 协议和服务器交互主要是进行数据的提交,通常数据的提交是通过 GET 和 POST 两种方式来完成
- curl文件上传有两种方式,一种是post_fileds,一种是infile
- 自制Javascript分页插件,支持AJAX加载和URL带参跳转两种初始化方式,可用于同一页面的多个分页和不同页面的调用
- JS使用post提交的两种方式
- 使用JS实现页面内跳转的两种方式
- js POST提交跳转页面
- 通过js判断访问请求来路进行页面跳转的示例
- php小代码----curl模拟登录及登录后并通过多线程进行重复post数据提交
- JS使用post提交的两种方式
- EasyUI 关于 panel,window,dialog 通过href加载页面,页面中引用的js不执行的解决方案
- 关于在servlet中实现页面跳转的两种方式
- 页面加载JS两种方式
- js用POST方式页面跳转,避免在地址栏中显示传递参数
- 通过两种方法实现在HTML页面加载完毕后运行某个js
- 通过curl模拟post和get方式提交的表单类
- Web前台数据提交(不跳转页面)的两种方式
- 关于ligerUI中ligerTree代码中的一个bug,造成该控件无法通过url的POST方式加载数据
- webView 加载页面的两种请求方式: get 和 post