A
A
Admiral892020-11-10 16:49:45
css
Admiral89, 2020-11-10 16:49:45

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

7 answer(s)
P
Peter, 2016-07-19
@petermzg

svg+css+javascript

A
Alexander Litvinenko, 2016-07-19
@edli007

nvd3.org

S
slowkazak, 2016-07-19
@slowkazak

morrisjs.github.io/morris.js

P
pup_pupets, 2016-07-29
@pup_pupets

I do this in d3js

A
Admiral89, 2020-11-22
@Admiral89

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

A
Alexander, 2020-11-10
@AleksandrB

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);

2) Apparently, you are making a GET request, despite the fact that POST is described in the dock. Add 3) Why is this still here?? And in general, it is not clear what this code does. Does it receive data? He sends them with a curl? What does he send with a curl? What does he take? Be specific. The documentation describes that you should make a post request to their server, passing data in json. How to do it here https://stackoverflow.com/questions/6213509/send-j...
curl_setopt($ch, CURLOPT_POST, true);
$str= serialize($_POST);

K
k2lhu, 2020-11-10
@k2lhu

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.

And the web address for accepting the request should be like this
https://partner.ru/api/v2/receipts

Where instead of partner.ru you need to substitute your domain, which leads to your application, where the specified method is implemented.
Did you do it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question