小编Tom*_*Tom的帖子

带有curl的PHP Google Geocode拒绝工作

我目前正试图通过在PHP页面中使用Google Geocode API来获取地址的lat和lng参数.

我目前有以下代码,但不知何故,它不能通过PHP工作,而将生成的地址复制到谷歌浏览器似乎确实有效.

任何人都可以在下面的代码中看到错误吗?

提前致谢!

汤姆

================================================== ==

返回的错误是:

( [error_message] => The 'sensor' parameter specified in the request must be set to either 'true' or 'false'. [results] => Array ( ) [status] => REQUEST_DENIED ) An error has occured: 1
Run Code Online (Sandbox Code Playgroud)

旧代码与过时的部分:

$googleQuery = $_POST['txtAdres'] . ',+' . $_POST['txtPostcode'] . '+' . $_POST['txtStad'] . ',+' . $_POST['txtLand'];
$googleQuery = str_replace(' ', '+', $googleQuery);

// retrieve the latitude & longitude from the address
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($googleQuery) . '&sensor=false'; …
Run Code Online (Sandbox Code Playgroud)

php curl google-maps geocoding google-api

0
推荐指数
1
解决办法
7294
查看次数

标签 统计

curl ×1

geocoding ×1

google-api ×1

google-maps ×1

php ×1