Geolocalização do Google usando informações da torre de celular

Estou tentando obter latitude e longitude das informações da torre de celular usandoAPI de geolocalização do Google. Ele requer um JSON válido com informações como MCC, MNC, cellId, lac, etc., Minha solicitação de postagem do PHP se parece com isso.

<?php
header("Access-Control-Allow-Origin: *");

$mcc = $_POST["mcc"];
$mnc = $_POST["mnc"];
$cellId = $_POST["cellId"];
$lac = $_POST["lac"];

$post_array = array(
                "cellId" => (int) $cellId,
                "locationAreaCode" => (int) $lac,
                "mobileCountryCode" => (int) $mcc,
                "mobileNetworkCode" => (int) $mnc,
            );

$post_data = json_encode(array('cellTowers' => array($post_array)));

echo $post_data;


$url = "https://www.googleapis.com/geolocation/v1/geolocate?key=".$api_key; // not including api key here but its there in my code

$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_HEADER => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json'
    ),
    CURLOPT_POSTFIELDS => $post_data
));
$result = curl_exec($ch);

echo "Result: ".$result;

curl_close($ch);

?>

No entanto, recebo um erro ao dizer solicitação incorreta na resposta. O erro é mostrado abaixo.

Result: {
 "error": {
  "errors": [
   {
    "domain": "geolocation",
    "reason": "invalidRequest",
    "message": "Bad Request"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}

Eu pensei que meu JSON não estava no formato correto, mas estava trabalhando com a seguinte execução de linha de comando, portanto esse não pode ser o problema.

$ curl -d @your_filename.json -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=API_KEY"

O comando acima no terminal fornece latitude e longitude corretamente com o mesmo JSON em um arquivo. O que estou fazendo errado ?

questionAnswers(1)

yourAnswerToTheQuestion