Y
Y
yourtdd2019-11-06 21:28:12
PHP
yourtdd, 2019-11-06 21:28:12

How to get specific value from SimpleXMLElement object?

Good afternoon or evening, I have bank-acquiring on servlets here (yes-yes), this is the answer to my request . I need to get OrderID, SessionID from the response to generate a link to redirect the buyer. But my variables are empty.
5dc310b63af37773596293.jpeg
I will be glad for any hints. Thanks in advance for your responses!
Response format:
5dc311b09f833501950135.jpeg
Response to sent xml:
5dc30b1b9e707020940820.jpeg
Here is the code for sending the request:

<?
$xml= 'Тут Xml';
$url = 'https://epaypost.fortebank.com/Exec';
$curl = curl_init($url);
$url = 'https://epaypost.fortebank.com/Exec';
$curl = curl_init($url);


curl_setopt ($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($curl);

if(curl_errno($curl)){
    throw new Exception(curl_error($curl));
}

curl_close($curl);

//Print out the response output.
$res = simplexml_load_string($result);

//print_r($res);
//Тут мои попытки получить нужное,но переменные пустуют.(Первый скрин)
 $orderid = (string)$res->OrderID;
 $sessionid = (string)$res->SessionID;  
 
header('Location: https://epay.fortebank.com/?' . http_build_query(array(
    'OrderID' => $orderid,
    'SessionID' => $sessionid
)));  
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2019-11-06
@yourtdd

var_dump((string)$res->Response->Order->OrderID);
var_dump((string)$res->Response->Order->SessionID);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question