How to read the response from the service?

Me one service sends here is POST'om:

Array
(
 [qw] => qaz
 [qwerty] => wsx
 [qwerty2] => edc
 [qwerty3] => rfv
 [qwerty4] => tgb
 [qwerty5] => yhn
 [qwerty6] => 
)


do this:

parse_str(file_get_contents("php://input"),$post_vars);

$qw = $post_vars['qw'];
$qwerty = $post_vars['qwerty'];
$qwerty2 = $post_vars['qwerty2'];
$qwerty3 = $post_vars['qwerty3'];
$qwerty4 = $post_vars['qwerty4'];
$qwerty5 = $post_vars['qwerty5'];
$qwerty6 = $post_vars['qwerty6'];


and trying to record in the database, but writes just the void

but when I write the whole thing in .txt file like so:

file_put_contents('test.txt', file_get_contents('php://input'));


the file comes:

Array
(
 [qw] => qaz
 [qwerty] => wsx
 [qwerty2] => edc
 [qwerty3] => rfv
 [qwerty4] => tgb
 [qwerty5] => yhn
 [qwerty6] => 
)


what am I doing wrong??
July 2nd 19 at 14:20
2 answers
July 2nd 19 at 14:22
Solution
I understand that the service sends data in the format var_dump'huh?
The review pointed to the fact that it is rather the output of print_r.
Surprisingly, but the precedents have already been.

The reverse parser to var_dump from colleagues from StackOverflow.
The reverse parser for print_r from commentators php.net and another from StackOverflow'CET.

You may also have to be wrong reading the documentation.
For example, the description of the specified service does not suspects a similar response format:

POST - An HTTP POST to a URL of your choosing with transaction details (in either an XML or CSV format)
GET - An HTTP GET to a URL of your choosing with transaction detail you define in the query string.


Dear developers, when faced with similar problems in the future! Make sure that you have correctly understood the documentation and the need for such tools parsing really there (;
No data types in the output, so no var_dump. Maybe print_r - Ignacio_Romaguera commented on July 2nd 19 at 14:25
and really. But such was being parsed: php.net/manual/en/function.print-r.php#93529 - Barrett.Little commented on July 2nd 19 at 14:28
: Thanks, I'll check on the results I will unsubscribe - alena_Hilll commented on July 2nd 19 at 14:31
:
The reverse parser for print_r made in this format:
Array
(
 [qw] => qaz
 [qwerty] => wsx
 [qwerty2] => edc
 [qwerty3] => rfv
 [qwerty4] => tgb
 [qwerty5] => yhn
 [qwerty6] => 
)


in this:
qazwsxedcrfvtgbyhn - alena_Hilll commented on July 2nd 19 at 14:34
added yet another option parser print_r - Barrett.Little commented on July 2nd 19 at 14:37
July 2nd 19 at 14:24
the file comes:

It means that the garbage you sent. Instead of the normally encoded application/x-www-form-urlencoded. Kick developers of this service, to fix this idiocy.

Well, or write a parser-a crutch.
the service sends a Method = POST, and Format = TXT - Ignacio_Romaguera commented on July 2nd 19 at 14:27
can even approximately show how to make the "parser-crutch" for that??? - Barrett.Little commented on July 2nd 19 at 14:30
Asking to change the format to something designed for machine processing. Normal form-urlencoded, multipartform, JSON or at least XML - alena_Hilll commented on July 2nd 19 at 14:33
and if the answer will come in xml then how to correctly parse? get data via php://input ?? but I do not understand... - alena_Hilll commented on July 2nd 19 at 14:36
To watch php://input to understand what these geniuses sent this time. If there really is a normal XML string that scorethere simplexml or another your favorite XML parser. - Barrett.Little commented on July 2nd 19 at 14:39
and service well-known foreign payment system! Want to customize notification purchase on my website in the admin =) - alena_Hilll commented on July 2nd 19 at 14:42
: and you can do that is
Array
(
 [qw] => qaz
 [qwerty] => wsx
 [qwerty2] => edc
 [qwerty3] => rfv
 [qwerty4] => tgb
 [qwerty5] => yhn
 [qwerty6] => 
)

convert to normal form? and it soared with these all day long, and I do not believe that in this service no one wrote (if it is not possible to do so) with this problem and so they left!! - alena_Hilll commented on July 2nd 19 at 14:45
,
it is a service well-known foreign payment system

And could you link to the documentation to throw? - Ignacio_Romaguera commented on July 2nd 19 at 14:48
and there the trick is that as such the documentation for developers is not present, only managers are in the office tab to configure the Event and the service simply gives the link for the basket, you edit prices etc - alena_Hilll commented on July 2nd 19 at 14:51
and ask records for anyone? No technical support or anything similar? - Ignacio_Romaguera commented on July 2nd 19 at 14:54
becomes more and more interesting. Open card is that for the system =) - alena_Hilll commented on July 2nd 19 at 14:57
: now throw off - alena_Hilll commented on July 2nd 19 at 15:00
: sent on e-mail documentation that I pulled off - Barrett.Little commented on July 2nd 19 at 15:03
In the submitted documentation, a choice of get data in following view:
POST method in xml format;
honey POST in csv format;
using GET;

If I understand correctly, that in the latter case, courtesy of comrades in the request body and still communicate print_r of all the parameters that they passed in line. But what's stopping you just read the data from the $_GET array? - alena_Hilll commented on July 2nd 19 at 15:06
in the documentation:
POST method in xml format;
honey POST in csv format;
honey POST in txt format;
The reverse parser for print_r made in this format:
Array
(
 [qw] => qaz
 [qwerty] => wsx
 [qwerty2] => edc
 [qwerty3] => rfv
 [qwerty4] => tgb
 [qwerty5] => yhn
 [qwerty6] => 
)


in this:
qazwsxedcrfvtgbyhn - Barrett.Little commented on July 2nd 19 at 15:09

POST - An HTTP POST to a URL of your choosing with transaction details (in either an XML or CSV format)
GET - An HTTP GET to a URL of your choosing with transaction detail you define in the query string.

Where do you see here POST in txt format? - Barrett.Little commented on July 2nd 19 at 15:12
according to the same table, with the GET method you can't obtain the data, but obviously it is not.

In any case, the service is clearly able to transmit data in a normal CSV and XML formats, which can run PHP. Also the service can send data in GET parameters, even easier. Why do you shy away from these options and trying to get the data in a way that not even described in the documentation? - alena_Hilll commented on July 2nd 19 at 15:15

Find more questions by tags PHPArraysRESTful APIWeb Development