PHP cURL 405 Method Not Allowed

I’m trying to get data from a person location (lat, long) from their HA data entity and bring it into a PHP array. so I can manipulate it in my program I’m writing.

I can’t seem to get the cURL info out of the RestAPI.

This is my attempt, it only give me a 405 error:

$ch = curl_init();
$data = array("entity_id" => "person.nathaniel");
$data_string = json_encode($data);

curl_setopt($ch, CURLOPT_URL, "https://ha.bak.com:8123/api/states");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Authorization: Bearer: " . $HA_Login_Key,
  "Content-Type: application/json",
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

curl_close($ch);

echo $output

However, if I change it to this I get a 401: Unauthorized error:

$ch = curl_init();
// $data = array("entity_id" => "person.nathaniel");
// $data_string = json_encode($data);

curl_setopt($ch, CURLOPT_URL, "https://ha.bak.com:8123/api/states/person.nathaniel");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Authorization: Bearer: eyJ0e...ijVQs0",
  "Content-Type: application/json",
));
// curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

curl_close($ch);

echo $output

If I call it by the command line I get a response:

curl -X GET -H "Authorization: Bearer eyJ0eXAiOi...HvECc" \
  -H "Content-Type: application/json" \
  https://ha.bak.com:8123/api/                       
{"entity_id":"person.nathaniel","state":"home","attributes":{"editable":false,"id":"nathaniel","latitude":49.9343061,"longitude":-155.5643584,"gps_accuracy":2,"source":"device_tracker.sm_g998b","user_id":"34543ad0017543650ea","entity_picture":"/api/image/serve/8b48352f/512x512","friendly_name":"Nathaniel"},"last_changed":"2022-08-22T07:56:33.567429+00:00","last_updated":"2022-08-22T08:08:41.641355+00:00","context":{"id":"01GB29HGD9NK5WHDBQXTF8JY4D","parent_id":null,"user_id":null}}%   

You have a colon after Bearer that shouldn’t be there.