I have a system that has 2 access types. One for the Administrator and the other for Users, the entries are in the same table, changing only the Status.
Eg: Administrator = A and Users = U.
But I have to do an integration to an external system, of which I am using curl
of PHP for this.
Then comes the doubt. As I use the same table, checking only the status at the time of access, so I get this way:
$dadosUsuario = array(
"user_id" => $usuario->id_usuario,
"name" => $_SESSION['NomeUsuario'],
.....
);
And then:
$data_string = json_encode($dadosUsuario);
$curl = curl_init('https://www.site-da-integracao.com.br/usuarios/');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$result = curl_exec($curl);
$error = curl_error($curl);
$response = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
Only when logged in as administrator, validation usually occurs, but as user, says the name is empty. But we give print_r()
in variable $dadosUsuario
the name appears ...
Does anyone know why this happens?