0
어떤 이유로 Google지도 이미지를 파일로 저장할 수 없습니다. 내가지도 URL로 이동하는 경우PHP가 외부 이미지를 파일로 저장할 수 없습니다.
$rs=mysqli_fetch_assoc(mysqli_query($dbh,"select latitude,longitude from locations where locid=$locid"));
$lat=$rs[latitude];$lon=$rs[longitude];
$mapUrl="https://maps.googleapis.com/maps/api/staticmap?center=$lat,$lon&zoom=13&size=400x280&key=".google_apikey;
$tmp="/srv/www/data/maps/tmp.png";
touch($tmp);chmod($tmp,0777);
file_put_contents($tmp,file_get_contents($mapUrl));
tmp.png is 0 bytes
에 저장된 결과 이미지 그러나 명시 적으로 무슨 잘못 여기에 확신
을하지 않음을 보여줍니다
여기 내 코드입니다. 이 페이지에 선택한 답변에
'blank'? 400x280의 모든 검정색 이미지를 얻었습니까? 또는 .png가 0 바이트입니까? 지금은 file_get_contents 및 file_put_contents 호출이 실제로 성공했다고 가정합니다. –
디버깅 할 때 함수를 중첩하지 마십시오. 나는 당신의 서버에서 SSL 실패를 추측하고있다. 그래서 file_get_contents는 아무것도 반환하지 않았다. var_dump (file_get_contents ($ mapUrl))가 비어 있지 않습니까? –
0 바이트는 f_g_c 호출이 실패했음을 의미하므로 이유를 알아 내야합니다. 어쩌면 구글이 귀하의 IP를 블랙리스트에 올렸습니다 –