Cyber​​plat Recharge API似乎无效

时间:2013-06-18 08:28:37

标签: php api curl

我目前正在研究Cyber​​plat的Recharge api。

客户希望我发送:

POST /cgi-bin/es/es_pay_check.cgi HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 498

inputmessage=0000037901SM000001180000011800000125%0D%0Aapi17032++
++++++++++00017033%0D%0A++++++++++++++++++++00000000%0D%0ABEGIN%0
D%0ASD%3D17031%0D%0AAP%3D17032%0D%0AOP%3D17034%0D%0ASESSION%3D4b3
4d1d400000cb80029%0D%0ANUMBER%3D8888888888%0D%0AAMOUNT%3D11%2E00%
0D%0AAMOUNT%5FALL%3D11%0D%0ACOMMENT%3D%0D%0A%0D%0AEND%0D%0ABEGIN+
SIGNATURE%0D%0AiQBRAwkBAABCiUs00dQBATG5AgDHdZ6RYHykL46QBaAvnHYaY4
p0pDjgjO4K1Iyj%0D%0AfSBSvCRpS%2F0EYO9NspuyLeANEQQkkGE%2F37gUxiPqz
AgStXjpsAHH%0D%0A%3DvSgb%0D%0AEND+SIGNATURE

我发送:

$ses = date("Ymdhis");
$url = "http://ru-demo.cyberplat.com/cgi-bin/DealerSertification/de_pay.cgi";
$data_string = "SD=XXXXXX&AP=XXXXXX&OP=XXXXX&SESSION=".$ses."&COMMENT=Test&NUMBER=9642065662&AMOUNT_ALL=10.0&AMOUNT=10.0";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Content-Length: '.strlen($data_string)));
curl_setopt($ch, CURLOPT_POSTFIELDS, "inputmessage=0000038801SM000001270000012700000125&".$data_string);
$result = curl_exec($ch);

var_dump($result);

这是以上述格式发送请求的正确方法吗? 我得到的回复是bool(false)

2 个答案:

答案 0 :(得分:0)

不要忘记将CURLOPT_POST设置为true,例如curl_setopt($ch, CURLOPT_POST, true);仅设置CURLOPT_POSFIELDS可能不会导致执行 POST 请求(尽管我不确定如何完全卷曲处理这个)

此外,您还想使用curl_setopt($ch, CURLOPT_VERBOSE, true);来显示调试信息。这将输出到STDERR,无论您的配置可能是什么。要更改它,请设置CURLOPT_STDERR选项。

答案 1 :(得分:0)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li class="amscheckout-row">1</li>
<li class="amscheckout-row">2</li>
<li class="amscheckout-row">3</li>
<li class="fields" id="anonymous_element_2">4</li>
<li class="amscheckout-row">5</li>
<li class="amscheckout-row">6</li>
<li class="amscheckout-row">7</li>
<li class="amscheckout-row">8</li>

这是正确的方法