0

I am working with Aerys but I have a problem. When I send my parameters through post I don't know how to access to the data.

In the documentation they use the following function:

$body = yield parseBody($request);

In the documentation, there are two functions to use the parseBody they use get or getArray with the key to get the data. As I said before I am sending an array of data but this array does not have a specific key to be accessed.

do you have any idea how to get the data of that array? If print $body it returns an object.

Aerys\ParsedBody Object ( [fields:Aerys\ParsedBody:private] => Array ( [0] => Array ( [0] => %222f384ae8-004b-44e1-8c6b-9b2a249b069f%22 ) ) )

kelunik
  • 6,750
  • 2
  • 41
  • 70
Jeff
  • 66
  • 2
  • can you try this and let me know `$values = array_values( $array); echo $values[0];` what does this echo you? –  Apr 26 '18 at 08:00
  • How does your actual request body look like, i.e. `var_dump(yield $request->getBody());`? – kelunik Apr 26 '18 at 20:34
  • @D.'s that is not going to work because `$body = yield parseBody($request)` return and Object. @kelunik the request is the Object that I referred in my comment above. `Aerys\ParsedBody Object` – Jeff Apr 26 '18 at 22:53

1 Answers1

0

I am not sure if this is the best way, but it works for me. I found this post about Access Private and Protected Properties of Objects in PHP I hope that it works for you.

$body = yield parseBody($request);
$boddy = (Array) $body;
$boddy = array_values($boddy);

I get the request from parseBody after that I make that an array, the problem that I have in this step is that I have as a key a class that is complex to access so I return the value from that array.

Jeff
  • 66
  • 2