1
I’m trying to catch the answer of a porst json with the guzzle in a simple php.
This is the function in a Laravel project that posts to a url. (I’m using var_dump to show the result in the terminal).
public function getPhotos($properties)
{
$codes = [];
foreach($properties as $property)
{
$codes[$property['codigo']] = $property['cod_filial'];
}
$client = new Client();
$response = $client->request('POST', 'http://local.app/file2.php', ['json' => \GuzzleHttp\json_encode($codes)]);
var_dump($response); exit;
}
This is the php file mapped to http://local.app/file2.php
<?php
$input = file_get_contents('php://input');;
$input = json_decode($input);
echo $input;
The Guzzle restores me empty. Can anyone help me? Thank you
2 different language and does not receive value at the same time, use
$.ajax
can help. Take the example: http://answall.com/questions/144032/redirecionar-p%C3%A1gina-passageResponse-do-ajax-para-uma-div/144050#144050– KingRider
But they are not different languages. Both are php.
– Ivan Moreira
I understand, but this using PDO? no and yet 2 language are different.
– KingRider
I got it. I just had to modify the
$response
for :$response->getBody()->getContents()
.– Ivan Moreira
Good Ivan! You can close or delete ;)
– KingRider