2

我一直在运营一个网站,为婚礼客人提供指导,帮助他们在接待处附近寻找酒店和 B&B。几个月来 API 没有问题,我的 homeowrk 和代码是可靠的并且可以正常工作。

今天晚上登录,我得到一个无效的密钥错误。我做了以下事情:

  • 检查我没有超过每天 25.000 个请求的“宽限”限制。事实上,婚礼直到今年晚些时候才举行,自 2 月以来总共有 124 个请求。
  • 刷新密钥并重新加载。没有喜悦。
  • 尝试重新设置引荐来源网址,但怀疑这会产生任何影响,正如预期的那样,它没有!

其他人有类似的问题,如果是这样,你是如何克服的?试图想出新的想法来解决这个问题。很茫然,直到今晚它都工作得很好!

一切顺利,

-布伦丹

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Accomodation</title>
<link rel='stylesheet' href='rsvp-load-styles.css' type='text/css' media='all' />
<link rel='stylesheet' id='colors-css'  href='rsvp-colors-fresh.css' type='text/css' media='all' />
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'></script>
    <script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?key=...&sensor=true">
    </script>
    <script type="text/javascript">
    //<![CDATA[

    var customIcons = {
      Blue: {
        icon: 'Blue.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      },
      Red: {
        icon: 'Red.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      }
    };

      // arrays to hold copies of the markers and html used by the side_bar 
      // because the function closure trick doesnt work there 
      var gmarkers = []; 

    function load() {
            var dunbrody = new google.maps.LatLng(52.241808,-6.945248);
            var myOptions = {
                center: dunbrody,
                zoom: 10,
                mapTypeId: google.maps.MapTypeId.SATELLITE
            };

            var map = new google.maps.Map(document.getElementById("map_canvas"),
            myOptions);
             var infoWindow = new google.maps.InfoWindow;

        // Change this depending on the name of your PHP file       
        downloadUrl("markers.php", function(data) {
            var xml = data.responseXML;
            var markers = xml.documentElement.getElementsByTagName("marker");
            for (var i = 0; i < markers.length; i++) {
                var name = markers[i].getAttribute("name");
                var point = new google.maps.LatLng(
                    parseFloat(markers[i].getAttribute("lat")),
                    parseFloat(markers[i].getAttribute("lng")));
                var type = markers[i].getAttribute("type");
                var html = "<b>" + name + "</b> <br/>";
                var icon = customIcons[type] || {};
                var marker = new google.maps.Marker({
                map: map,
                position: point,
                icon: icon.icon,
                shadow: icon.shadow
            });
          bindInfoWindow(marker, map, infoWindow, html);
              // save the info we need to use later for the side_bar
            gmarkers.push(marker);
        }
      });
      }

          function bindInfoWindow(marker, map, infoWindow, html) {
            google.maps.event.addDomListener(marker, 'click', function() {
            infoWindow.setContent(html);
            infoWindow.open(map, marker);
            });
        }

            function downloadUrl(url, callback) {
                var request = window.ActiveXObject ?
                new ActiveXObject('Microsoft.XMLHTTP') :
                new XMLHttpRequest;

                request.onreadystatechange = function() {
                if (request.readyState == 4) {
                    request.onreadystatechange = doNothing;
                    callback(request, request.status);
                }
            };

                request.open('GET', url, true);
                request.send(null);
            }

            function myclick(i) {
                google.maps.event.trigger(gmarkers[i], "click");
            }

            function doNothing() {}

      //]]>
      </script>
</head>
<body class="wp-admin no-js  options-general-php" onload="load()" onUnload="GUnload()"><div id="map_canvas" style="width: 100%; height: 50%;"></div><div id="details" style="width: 100%; height: 50%;overflow:scroll;"><table><tr><th align="left" valign="top" colspan="2"><b>Dunbrody Country House Hotel</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>The reception will be held here.</td></tr><tr><td  align="right" valign="top">Tel:</td><td>+353 (0)51 389 600</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://dunbrodyhouse.com/" target="_blank">http://dunbrodyhouse.com/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(1-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Marsh Mere Lodge</b></th></tr><tr><td  align="right" valign="top">Details:</td><td></td></tr><tr><td  align="right" valign="top">Tel:</td><td>+353(0) 5138 9186</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.marshmerelodge.com/" target="_blank">http://www.marshmerelodge.com/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(2-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Glendine Country House</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Also has a 2 bed cottage - sleeps 4</td></tr><tr><td  align="right" valign="top">Tel:</td><td>+353(0) 5138 9500</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.glendinehouse.com/" target="_blank">http://www.glendinehouse.com/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(3-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Arthurs Rest</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Peggy Murphy arthursrest@eircom.net 
Immaculate and comfortable - ideal for families.</td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353(0) 5138 9192</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="" target="_blank"></a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(4-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Kilmokea House</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>A member of Hidden Ireland, Kilmokea offers beautiful gardens, relaxing formal rooms and is ideal for those looking for quiet.</td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353(0) 5138 8109</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.kilmokea.com" target="_blank">http://www.kilmokea.com</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(5-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>The Loft Self Catering</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Peggy Murphy, Arthurstown.
Charming converted grain loft, sleeps 8 - perfect for younger groups. </td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5138 9102</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.discoverireland.ie/Where-To-Stay/the-loft/60533" target="_blank">http://www.discoverireland.ie/Where-To-Stay/the-loft/60533</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(6-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Ann Walsh, Self Catering</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Ballytarsna, Ballycullane. From �130 4 bedroom farmhouse - sleeps 8.</td></tr><tr><td  align="right" valign="top">Tel:</td><td></td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="" target="_blank"></a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(7-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Duncannon Holiday Homes</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>3 bedroom homes set in the heart of Duncannon village. Sleeps 6. From �120 </td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5138 9188</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="" target="_blank"></a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(8-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Beachview Self Cateringeps </b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Sleeps 6</td></tr><tr><td  align="right" valign="top">Tel:</td><td></td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.selfcateringhomes.ie/index.php?route=showhome&pid=181#owner" target="_blank">http://www.selfcateringhomes.ie/index.php?route=showhome&pid=181#owner</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(9-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Coastguard Cove -3 bed</b></th></tr><tr><td  align="right" valign="top">Details:</td><td></td></tr><tr><td  align="right" valign="top">Tel:</td><td></td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.daft.ie/searchshortterm.daft?id=18365" target="_blank">http://www.daft.ie/searchshortterm.daft?id=18365</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(10-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Rivervalley Farmhouse</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>anne@rivervalleyfarmhouse.com</td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5156 1354 </td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.rivervalleyfarmhouse.com/" target="_blank">http://www.rivervalleyfarmhouse.com/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(11-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>The Haven Lodge </b></th></tr><tr><td  align="right" valign="top">Details:</td><td>ellencolfer@hotmail.com </td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5156 1319</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.hooktourism.com/where_to_stay/detail/the_haven_lodge_bed_breakfast/ " target="_blank">http://www.hooktourism.com/where_to_stay/detail/the_haven_lodge_bed_breakfast/ </a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(12-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Carrig House B&B</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Nicola & Nicholas Howlin nhowlin@eircom.net http://www.bandbwexford.com </td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5156 1101</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.hooktourism.com/where_to_stay/detail/carraig_house_bb/" target="_blank">http://www.hooktourism.com/where_to_stay/detail/carraig_house_bb/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(13-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Herrylock Cottage B&B</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>harrylock@eircom.net  Prop: Anna and David Nash Hook Head Fethard-on-Sea Co. Wexford </td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5139 7029</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="Co. Wexford http://www.hooktourism.com/where_to_stay/detail/herrylock_bb/" target="_blank">Co. Wexford http://www.hooktourism.com/where_to_stay/detail/herrylock_bb/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(14-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Groveside Farm B&B</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Ballyharty, Kilmore, Co.Wexford. �&lt;/td></tr><tr><td  align="right" valign="top">Tel:</td><td>No: +353 (0) 5391 35305</td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="http://www.grovesidefarm.com/" target="_blank">http://www.grovesidefarm.com/</a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(15-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr><tr><th align="left" valign="top" colspan="2"><b>Crooke Church</b></th></tr><tr><td  align="right" valign="top">Details:</td><td>Tying the knot here.</td></tr><tr><td  align="right" valign="top">Tel:</td><td></td></tr><tr><td  align="right" valign="top">Link:</td><td><a href="" target="_blank"></a></td></tr><tr><td  align="right" valign="top">Google Map:</td><td><a href="javascript:myclick(16-1)">[Show on Map]</a></td></tr><tr><th align="left" valign="top" colspan="2"><br></th></tr></table>    </div>
</body>
</html>
4

1 回答 1

2

尽管清除引荐来源网址可以解决问题,但这确实意味着您的密钥很容易被滥用(因为您没有指定可以在哪里使用它)。我已经将它编辑了,尽管它并没有完全隐藏。

您的引荐来源网址字符串必须与您的地图所在的 URL 相匹配——这意味着必须/*在域名末尾使用,以表明该域中的任何 URL 都是可以接受的。如果最后没有星号,则只有默认页面会匹配——如果有明确的重定向到另一个页面,即使这样也不会匹配。

www.exampledomain.com/*将匹配该域中的任何页面。
www.exampledomain.com/惯于。

如果您的页面可以使用www.或丢失该页面,或者如果您有其他子域,则需要使用*.exampledomain.com/*.

如果您的站点使用 HTTPS,则需要明确指定该协议。

于 2012-05-13T23:37:26.017 回答