Retrieving a guzzle JSON post with simple php -


i'm trying retrieve result guzzle json post using simple php.

this function in file1.php edited file in laravel 5.3 project

    public function getphotos($properties)     {         $codes = [];         foreach($properties $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;     } 

and file in local url http://local.app/file2.php edited file in project outside laravel , have endpoint configured pointing.

<?php $input = file_get_contents('php://input');; $input = json_decode($input); return $input; 

guzzle response empty , i'm not figuring out i'm doing wrong.

can me? lot.

1) try in first file:

var_dump($response->getbody()->getcontents()); // or var_dump((string)$response->getbody()); 

2) read the documentation json option more carefully, option accepts simple php array, should not call json_encode manually.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -