【问题标题】:Getting a HTTP 403 Forbidden Error - Google Geocode API Request with PHP获取 HTTP 403 禁止错误 - 使用 PHP 的 Google Geocode API 请求
【发布时间】:2015-03-16 08:16:57
【问题描述】:

我正在尝试使用 PHP 执行 Google 地理编码请求,但我得到了 403 Forbidden 答案:

警告:file_get_contents(http://maps.google.com/maps/api/geocode/json?address=Bahnhofstrasse+1,+Zurich&sensor=false):打开流失败:HTTP 请求失败! HTTP/1.0 403 Forbidden in ...

在不同的服务器上使用相同的代码,请求可以工作。谷歌是否有可能阻止我来自特定服务器的请求?请求太多?

这是我的代码:

error_reporting(E_ALL ^ E_NOTICE);
$request = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=Bahnhofstrasse+1,+Zurich&sensor=false");
$json = json_decode($request, true);
print_r($json);

【问题讨论】:

    标签: php json geocode


    【解决方案1】:

    是的,您可能在服务器上发送了太多请求。 他们限制每个 IP 每天的 API 请求。

    您可以在 API 网站上查看更多信息。 https://developers.google.com/maps/documentation/business/articles/usage_limits

    【讨论】:

    • 似乎我每秒对我的 php 文件执行了太多请求。我通过我们服务器上的 Windows 任务解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 1970-01-01
    • 2017-04-09
    • 2015-02-12
    相关资源
    最近更新 更多