Google 地点评论 API - 照片 return 403 页面加载

Google Place Reviews API - Photos return 403 on pageload

我目前正在使用 Google Places API 将评论拉到网页上。除了留下评论的人的照片外,一切正常。当试图获取评论者的照片时,它会在每隔一个页面加载时返回 403 Forbidden。好像是有速率限制吧?

问题是我找不到任何关于速率限制以及如何让图片正常显示的文档。我在文档中遗漏了什么吗?

我的API电话是这样的;

https://maps.googleapis.com/maps/api/place/details/json?placeid=PLACE_ID&key=API_KEY

那个 returns 相当长的 JSON 数组(我已经把它砍掉了)。其中一个字段是;

{
   "result" : {
      "reviews" : [
         {
            "profile_photo_url" : "//lh5.googleusercontent.com/url/photo.jpg"
         }
      }
   }
}

就像我说的,如果我刷新几次,它会导致图像获取请求出现 403 错误。无论如何要缓存或允许更多请求?

我发现了为什么会这样。这与照片媒体的速率限制有关,这就是它在控制台中给出 403 错误的原因。 developer docs 概述了所请求媒体的限制。

文档摘录...

The Google Places API Web Service enforces a default limit of 1,000 free requests per 24 hour period, calculated as the sum of client-side and server-side requests. If your app exceeds the initial limit, the app will start failing. You can increase this limit free of charge, up to 150,000 requests per 24 hour period, by enabling billing on the Google API Console to verify your identity. A credit card is required for verification. We ask for your credit card purely to validate your identity. Your card will not be charged for use of the Google Places API Web Service.

最好的办法是在请求媒体时缓存媒体以避免超过限制,这在您多次重新加载页面以测试本地开发更改时特别有用。