Php 从谷歌纬度检索纬度和经度
我正在做一个项目,我想用这段代码检索纬度和经度,但事实并非如此 返回我…请检查此代码Php 从谷歌纬度检索纬度和经度,php,Php,我正在做一个项目,我想用这段代码检索纬度和经度,但事实并非如此 返回我…请检查此代码 <?PHP header('Content-Type: text/plain'); //$userkey='AIzaSyB2hw658V7RSzEYgwSHwYkaLm_505gqLhs'; //$url='https://www.googleapis.com/latitude/v1/currentLocation?key='.$userkey.'&type=json'; $userId = '
<?PHP
header('Content-Type: text/plain');
//$userkey='AIzaSyB2hw658V7RSzEYgwSHwYkaLm_505gqLhs';
//$url='https://www.googleapis.com/latitude/v1/currentLocation?key='.$userkey.'&type=json';
$userId = '30811844108.apps.googleusercontent.com';
$url = 'http://www.google.com/latitude/apps/badge/api?user='.$userId.'&type=json';
$content = file_get_contents( $url );
$json = json_decode( $content );
$coord = $json->features[0]->geometry->coordinates;
$lat = $coord[1];
$lon = $coord[0];
echo $lat.' x '.$lon;
//$newurl="http://jecrcgps.betu.tk/data.php?lat=$lat&lon=$lon";
//header("location: $newurl");exit;
?>
您确定这是正确的$userid吗? 我正在测试那个用户$iserid,刚刚得到了用户标识符的格式错误
也许你应该试试$userid=30811844108 你确定那是你的谷歌用户名吗?我不确定,但可能是30811844108而不是30811844108.apps.googleusercontent.com。