<?php
$origin = $_POST['origin'];
$address = explode("\n",$_POST['addresses']);
$address = implode("|",$address);
$data = array('origin'=>$origin,
'destination'=>$origin,
'waypoints'=>'optimize:true|'.$address,
'key'=>'MYAPIKEY',
'sensor'=>'false');
$data = http_build_query($data);
$url = "https://maps.googleapis.com/maps/api/directions/json?".$data;
echo file_get_contents($url);
?>
$ _ POST [ '起源'] = 「Frimurarvägen20Skärholmen」
$ _ POST [ '地址'] =「Vasagatan 7,111 20斯德哥爾摩\nKungsträdgårdsgatan20,111 47斯德哥爾摩\nUlvsundavägen160,168 67布洛馬\ nHuvudstagatan 2A 171 44索爾納「
我的嘗試: 用urlencode郵件PARAM。 str_replace函數與%的空間20
嘗試改變休假 – rupesh
的問題可能是與像'A'和'A'字符。閱讀https://developers.google.com/maps/documentation/directions/web-service-best-practices#BuildingURLs – duncan
@duncan當我使用的瀏覽器鏈接..它返回一個結果。但隨着file_get_content它不「T – PaulE