我正在使用下面的脚本显示谷歌地图。
它的正常工作,但有时我得到一个警告消息:无法打开流:HTTP请求失败! HTTP/1.0 403 staticmap中的禁止警告错误google api
<?php
$src = 'https://maps.googleapis.com/maps/api/staticmap? center=40.714728,-73.998672&markers=color:red%7Clabel:C%7C40.718217,-73.998284&zoom=12&size=600x400';
$time = time();
$desFolder = '';
$imageName = 'google-map.PNG';
$imagePath = $desFolder.$imageName;
file_put_contents($imagePath,file_get_contents($src));
?>
<img src="<?php echo $imagePath; ?>"/>
一个PHP错误遇到
严重性:警告
消息: 的file_get_contents(https://maps.googleapis.com/maps/api/staticmap?center=39.9834656,-75.1499542&15&size=250x250&maptype=hybrid&markers=color:red%7Ccolor:red%7Clabel:A%7C39.9834656,-75.1499542&sensor=true): 失败开放式流:HTTP请求失败! HTTP/1.0 403禁止。
多次使用时,file_get_contents可能存在安全问题。 因此,请帮助我提供替代解决方案以取代file_get_content或我如何处理此警告。
感谢您的支持。
这是类似于http: //stackoverflow.com/questions/17302757/google-maps-api-v3-error-403-forbidden-access-for-too-many-pageviews? – WEBjuju
@ WEBjuju,感谢您的帮助。我已经检查过您的共享网址,但我没有得到我的解决方案,因为我需要使用纬度和经度显示地图。 – Manraj
已经使用谷歌地图api很好,如果太多的通话在短时间内发生,其中一些由于速率限制而失败。在这种情况下可能吗? – WEBjuju