【问题标题】:Sagepay cURL data postingSagepay cURL 数据发布
【发布时间】:2010-07-16 11:28:47
【问题描述】:

谁能告诉我我在下面的代码中哪里出错了。

我刚刚按照 sagepay 建议的格式将交易信息发布到 sagepay。所以我使用 cURL 来发布这些信息。我的疑问出现在第 10 行。请告知我会使用此语句创建新的连接吗?

它会开始无限循环吗?

<?
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);
?>

【问题讨论】:

  • 究竟是什么问题(除了询问新连接)??
  • 我的请求超时并且到达目标 URL 的过程很慢。这句话会做吗?

标签: php curl payment-gateway


【解决方案1】:

这对我有用:

<?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);

?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    • 1970-01-01
    • 2011-12-28
    • 2012-03-26
    • 2023-03-09
    • 1970-01-01
    相关资源
    最近更新 更多