[英]How can I send requests via HTTP Post to URL in php
I have website that has page for donation. 我的网站上有捐赠页面。 Merchants registered on the Gateway are to send transaction requests to GTPay via HTTP Post to URL https://ibank.gtbank.com/GTPay/Tranx.aspx
在网关上注册的商户将通过HTTP Post发送到GTPay的交易请求到URL https://ibank.gtbank.com/GTPay/Tranx.aspx
When I submit my request I see this page of the above URL displayed inside my donation page instead of taking me to the URL Below is my code: 当我提交请求时,我看到上述URL的页面显示在捐赠页面中,而不是带我到URL。以下是我的代码:
$url = 'https://ibank.gtbank.com/GTPay/Tranx.aspx';
$fields = array(
'gtpay_mert_id' => urlencode($gtpay_mert_id),
'gtpay_tranx_id' => urlencode($gtpay_tranx_id),
'gtpay_tranx_amt' => urlencode($gtpay_tranx_amt),
'gtpay_tranx_curr' => urlencode($gtpay_tranx_curr),
'gtpay_cust_id' => urlencode($gtpay_cust_id),
'gtpay_tranx_noti_url' => urlencode($gtpay_tranx_noti_url),
'gtpay_hash' => urlencode($gtpay_hash)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$form_files=array();
$form_options=array( 'cookies' => array( 'auth' => $auth ) );
http_post_fields($url, $fields, $form_files, $form_options);
//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, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Request made using cURL won't take you to the URL. 使用cURL进行的请求不会将您带到该URL。 It will just process the request and return data back to your end.
它只会处理请求并将数据返回到您的终端。
You need to submit your request using an HTML form with your fields. 您需要使用带有字段的HTML表单提交请求。
Something like this: 像这样:
<form action=" https://ibank.gtbank.com/GTPay/Tranx.aspx" method="post">
<!-- Saved buttons use the "secure click" command -->
<input type="hidden" name="cmd" value="_s-xclick">
<!-- Saved buttons are identified by their button IDs -->
<input type="hidden" name="hosted_button_id" value="221">
<!-- Saved buttons display an appropriate button image. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.