我有php文件,我想在同一文件中提取地理位置。但是从不同位置工作的人总是能得到同样的回报。
<?php session_start();
function curl_request()
{
$url = "https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyCNxfsOkFGl0nVamci_dr45ivjgnBdituI";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$jsondata = json_decode($result, true);
$_SESSION['latitude']=$jsondata['location']['lat'];
$_SESSION['longitude']=$jsondata['location']['lng'];
curl_close($ch);
return $result;
}
/** @var [type] [description] */
$coord = curl_request();
?>