doujing5937 2015-11-01 11:22
浏览 114

如何通过HTTP Post将请求发送到php中的URL

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

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 = '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);
  • 写回答

1条回答 默认 最新

  • drslez4322 2015-11-01 11:48
    关注

    Request made using cURL won't take you to the 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.

    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>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法