Hello, for all other requests via POST the return is ok '200', however for the registration and password validation the return is 401. Following the same line of code as the example like this. Does anyone have a solution?
<?php
function registerUser($username,$password,$email,$token){
$url = 'http://localhost:5400/api/v1/users/register';
$ch = curl_init($url);
$data = array(
"username" => $username,
"password" => strtoupper(hash("sha256", $password)),
"email" => $email
);
$payload = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS,$payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type:application/json','Authorization: Bearer '.$token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$status = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return $status;
}
?>