Estou testando o PHP e estou enviando dados via "Curl" para outro arquivo .php e preciso retornar dados para o arquivo que enviou os dados.
Algo assim:
envia.php
<?php
$iniciar = curl_init();
$dados = array(
'cTabela' => 'Teste',
'cCampo' => 'nome'
);
$dadosArray = json_encode($dados);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json';
$headers[] = 'Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$optArray = array(
CURLOPT_URL => 'http://localhost/classes/post.php',
CURLOPT_PORT => 8080,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $dadosArray,
);
$response = curl_setopt_array( $iniciar, $optArray );
$return["body_array"] = curl_exec($iniciar);
$return["body"] = json_decode($return["body_array"], true );
$return["http"] = curl_getinfo($iniciar);
$return["error"] = curl_error($iniciar);
echo '<pre>';
var_dump( $return["body_array"] );
var_dump( $return["body"] );
var_dump( $return["http"] );
var_dump( $return["error"] );
curl_close( $iniciar );
?>
post.php
<?php
$rec = json_decode( file_get_contents( "php://input", 1 ) ) ;
return $rec->cTabela;
Como posso recuperar dentro do envia.php o return do post.php ?