PHP, CURL.curl_exec会返回什么?
我正在尝试使用支付处理器设置 API。以下是他们提供给我的代码。我想要的$result变量中有一些信息,我不明白的是哪种类型的变量是“$result”,以及我如何从中获取某些数据。打印$result显示“交易 ID 为: xxxx 状态为接受”。我基本上想要的是只获取交易ID并将其存储在变量中。
foreach($_POST as $k=>$v) $$k=urldecode($v);
$urladdress = "https://example.com/accapi/process.php";
$api_id = "dddd";
$api_pwd = "yyyyy";
$api_pwd = md5($api_pwd.'s+E_a*');
$data = "user=".$user. "&testmode=".$testmode."&api_id=".$api_id. "&api_pwd=".$api_pwd."&amount=".$amount."&paycurrency=".$currency."&comments=".$comments."&fee=".$fee."&udf1=".$udf1;
// Call STP API
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"$urladdress");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); //use this to suppress output
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);// tell cURL to graciously accept an SSL certificate
$result = curl_exec ($ch) or die(curl_error($ch));
echo $result;
echo curl_error($ch);
curl_close ($ch);
感谢您的帮助