Answer the question
In order to leave comments, you need to log in
How to accept post data from evator in php?
Good afternoon friends!
Please help me with this problem. It is required to accept data Checks v2 from the evator, which are sent using the $_POST method and they have documentation: https://api.evotor.ru/docs/#tag/Vebhuki-uvedomleni...
I tried to do this first, without specifying a token and authorization , through arrays #_POST and
Then tried to get this data through CURL. Played with the addition of a token. No matter what I do, the data does not come. Help if anyone knows, because I'm already *tired* of this.
It looks like this now:file_get_contents('php://input');
$url = 'https://partner.ru/api/v2/receipts';
$ch = curl_init($url);
$headers = array();
$headers[] = "Accept: application/vnd.evotor.v2+json";
$headers[] = "Content-Type: application/vnd.evotor.v2+json";
$headers[] = "Authorization: Bearer ТУТ_ТОКЕН";
$headers[] = "Accept-Language: en";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$curldata = json_decode($data, true);
if(!$curldata){
$curldata = "no curlData";
}
curl_close($ch);
file_put_contents('logs.txt', "DB: ". date("H:m:s d.m.Y") . "\r\n" . $data . "\r\n---------------------------\r\n", FILE_APPEND);
Answer the question
In order to leave comments, you need to log in
Dear friends!
Thank you all for your answers, unfortunately none of them are correct.
I was able to understand what was the reason after the SRC attribute data was no longer displayed in mail clients (except for Yandex mail). This is what led me to the idea of a series of experiments, which eventually ended with the solution of a series of tasks at once. With the code, everything is in order, it works
$postData = file_get_contents('php://input');
In vain removed from the question. It even works very well.
Thank you. PS> who is interested in the answer, I shot a video on the topic: https://vk.com/lroot?w=wall557276355_103
1) Do you understand that you decode a json string into a php array, and then try to write it down?
Write curl data via
$curldata = json_decode($data, true);
file_put_contents('logs.txt', "CR: " . date("H:m:s d.m.Y") . "\r\n" . $data. "\r\n\r\n", FILE_APPEND);
curl_setopt($ch, CURLOPT_POST, true);
$str= serialize($_POST);
It is not clear why you use curl here at all, the documentation clearly says -
After payment, sends a check to a third-party service. The request body contains one or more receipts.
Waits for a 200 OK response from a third-party service. If no response is received within 10 seconds, the Cloud resends the notification.
https://partner.ru/api/v2/receipts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question