Boa tarde Senhores,
Estou com um código que em sua requisição recebe uma resposta em JSON, a parte da requisição esta perfeita, porem não consigo pegar os elementos do JSON para encpasular em uma string ou variavel.
$data = array(
"PropertyName"=> "IdMessage", "Condition"=> "Contains", "Value"=> "537552");
$data_string = json_encode($data);
$data_string = “[”.$data_string."]";$header = array();
$header[] = ‘accept: application/json’; $header[] = ‘Content-type: application/json-patch+json’; $header[] = 'Authorization: '.$Authorization; $ch = curl_init(‘<a href="http://integration.systemsatx.com.br/Tracking/Message/List">http://integration.systemsatx.com.br/Tracking/Message/List</a>’); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Length: 105534’)); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, $header); $response = curl_exec ($ch); // Takes raw data from the request // Decoding JSON data $decodedData = json_decode($response, true); var_dump($decodedData);?>
Arquivo retornado
array(1) { [ 0 ]=> array(23) { [ “IdMessage” ]=> int(537552) [ “MessageCode” ]=> string(4) “K9_1” [ “MessageDirection” ]=> int(2) [ “IdWorkFunction” ]=> NULL [ “IdOperationalFunction” ]=> NULL [ “RuleIntegrationCode” ]=> NULL [ “TrackedUnit” ]=> string(7) “EVU8C11” [ “IdTrackedUnit” ]=> int(3801) [ “TrackedUnitIntegrationCode” ]=> NULL [ “APPIntegrationCode” ]=> NULL [ “TripCode” ]=> NULL [ “SendDate” ]=> string(20) “2021-10-28T19:42:25Z” [ “ReceiveDate” ]=> string(24) “2021-10-28T19:42:27.433Z” [ “ReadDate” ]=> NULL [ “SenderPersonName” ]=> string(25) “OLIVALDO MOREIRA DA SILVA” [ “SenderPersonIntegrationCode” ]=> NULL [ “ReaderPersonName” ]=> NULL [ “ReaderPersonIntegrationCode” ]=> NULL [ “Text” ]=> string(7) “Manobra” [ “Description” ]=> NULL [ “Lat” ]=> float(-3.77614) [ “Long” ]=> float(-38.6047) [ “Attributes” ]=> NULL } } array(1) { [ 0 ]=> string(9) “IdMessage” }
Já criei um importador por arquivo Excel cujo usavamos uma LIB em java e encapsulava as String com o metodo rs.getString e por ai conseguia fazer as inserts…