使用 PHP 获取坐标


get coordinates with php

以下代码应返回该地点的坐标,但它仅返回逗号....

<?php
function getCoordinates($address){
$address = str_replace(" ", "+", $address);
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
$response = file_get_contents($url);
$json = json_decode($response,TRUE);
return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);
}

echo getCoordinates('740 Story Rd San Jose CA 95122');
?>

我已经解决了一半的问题:

{ "error_message" : "您已超出此 API 的每日请求配额。", "结果" : [], "状态" : "OVER_QUERY_LIMIT" }

因为我没有设置我的API密钥,所以我的访问权限有限。

谁能告诉我如何在 php 中设置我的 APIkey?