1

我目前正在研究 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)

4

2 回答 2

0

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

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

于 2013-06-18T08:31:31.440 回答
0
$url="http://ru-demo.cyberplat.com/cgi-bin/DealerSertification/de_pay.cgi?inputmessage=".urlencode($data_string );
$opts = array( 
  'http'=>array( 
    'method'=>"GET", 
    'header'=>array("Content-type: application/x-www-form-urlencoded\r\n") 
  ) 
); 

这是正确的方法

于 2017-10-03T10:50:56.733 回答