Answer the question
In order to leave comments, you need to log in
How to make xml request in yii2?
Good day! There is an API and it says
Data exchange is carried out by XML requests to the address https://api.privatbank.ua/p24api/pay_pb
Answer the question
In order to leave comments, you need to log in
Most likely it means that you will receive an answer in xml format. Try to make a normal POST request.
In this case, xml is passed in the body of the request. In this case, it is more convenient to send via curl:
<?php
$url = "https://api.privatbank.ua/p24api/pay_pb";
$xml = '
<?xml version="1.0" encoding="UTF-8"?>
<request version="1.0">
<merchant>
<id>75482</id>
<signature>99730232b2f984c571507a0e74595e777afd0428</signature>
</merchant>
<data>
<oper>cmt</oper>
<wait>0</wait>
<test>0</test>
<payment id="1234567">
<prop name="b_card_or_acc" value="4627081718568608" />
<prop name="amt" value="1" />
<prop name="ccy" value="UAH" />
<prop name="details" value="test%20merch%20not%20active" />
</payment>
</data>
</request>
';
$headers = array(
"Content-type: text/xml",
"Content-length: " . strlen($xml),
"Connection: close",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
echo $data;
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question