Sagepay cURL data posting

限于喜欢 提交于 2019-12-13 07:35:33

问题


can any one please let me know where i did the mistake on the below code.

I have just post the transaction information to sagepay as the format suggested by sagepay. so i have used cURL to post those information. here my doubt is appears on the line number 10. please advise will i use this statement for fresh connection creation?

will it start infinite loop?

<?
1   $curlSession = curl_init();
2   curl_setopt ($curlSession, CURLOPT_URL, $url);
3   curl_setopt ($curlSession, CURLOPT_HEADER, 0);
4   curl_setopt ($curlSession, CURLOPT_POST, 1);
5   curl_setopt ($curlSession, CURLOPT_POSTFIELDS, $data);
6   curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1); 
7   curl_setopt($curlSession, CURLOPT_TIMEOUT,180); 
8   curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
9   curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
10  curl_setopt($curlSession, CURLOPT_FRESH_CONNECT, 1);
11  $rawresponse = curl_exec($curlSession);
?>

回答1:


Here's what works for me:

<?php

    $curlSession = curl_init();

    curl_setopt($curlSession, CURLOPT_URL, $url);
    curl_setopt($curlSession, CURLOPT_HEADER, 0);
    curl_setopt($curlSession, CURLOPT_POST, 1);
    curl_setopt($curlSession, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);

    $response = split(chr(10), curl_exec($curlSession));

    curl_close ($curlSession);

?>


来源:https://stackoverflow.com/questions/3264328/sagepay-curl-data-posting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!