【问题标题】:Google Place Photo Requests Broken?Google Place 照片请求中断?
【发布时间】:2013-08-27 19:30:47
【问题描述】:

我们正在尝试使用 Google 地方照片请求

(https://developers.google.com/places/documentation/photos#place_photo_requests)

获取照片的 API,但不断获取超出配额的图像。

我们已经注册了一个付费帐户,并且设置了一个全新的帐户,并且继续收到此错误。

为了重现我们:

1) 首先通过 PHP 从服务器 (/maps/api/place/details/json) 运行 Place Details 请求。

2) 然后从这个结果集中我们获取了(['result']['photos'][0]['photo_reference']) photoreference。

3) 使用我们称为 /maps/api/place/photo 的 photoreference、key、sensor 和 maxwidth 变量(通过 PHP)。

我们似乎无法让它发挥作用。有没有其他人成功使用过这个或有什么建议?

【问题讨论】:

  • 你解决过这个问题吗?我得到了同样的结果,即使 8 年后也看到它被提及很多

标签: php google-places-api google-places


【解决方案1】:

听起来您要么向我们发送了很多请求,要么没有将密钥添加到照片提取中。你有任何成功的请求吗?如果没有,我怀疑您的钥匙丢失和/或不正确。

【讨论】:

  • 我们尝试使用全新的密钥,但照片请求也不起作用。奇怪的是,当我们使用 Google Places API 文档中提供的示例时,即使这样也会返回超限图像。我们非常小心地确保我们包含 API 密钥。有趣的是,JavaScript API 可以很好地返回图像,它只是我们似乎无法使用的服务器端。
【解决方案2】:

试试这个代码。它对我有用

<h3>Images From Google </h3>
<?php

$company_name = 'walmart';
$data_ref = file_get_contents("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=Latitude ,Longitude&radius=100&name=".$company_name."&types=store&sensor=false&key=MYKEY");


$data_ref_de = json_decode($data_ref);

if($data_ref_de->status=='OK')
{


    foreach($data_ref_de->results as $result)
    {
        if(isset($result->photos) && count($result->photos))
        {
            foreach($result->photos as $photos)
            {?>
               //Display Image

            <img src="https://maps.googleapis.com/maps/api/place/photo?maxwidth=600&photoreference=<?php echo $photos->photo_reference; ?>&sensor=true&key=MYKEY" />

            <?php 
            }
        }
    }

}

还要确保您已启用Places API 服务

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多