Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从谷歌纬度检索纬度和经度_Php - Fatal编程技术网

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。