PHP, CURL. Was gibt curl_exec zurück?
Ich versuche, eine API mit einem Zahlungsprozessor einzurichten. Unten ist der Code, den sie mir zur Verfügung gestellt haben. Die Variable $ result enthält einige Informationen, die ich haben möchte. Was ich nicht verstehe, ist, welcher Variablentyp '$ result' ist und wie ich bestimmte Daten daraus entnehmen kann. Beim Ausdruck des Ergebnisses $ wird "Transaktions-ID ist: xxxx-Status ist AKZEPTIERT" angezeigt. Grundsätzlich möchte ich nur die Transaktions-ID nehmen und in einer Variablen speichern.
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);
Danke für deine Hilfe