【发布时间】:2013-09-13 10:29:38
【问题描述】:
在我的业务中,我必须在我的应用程序中使用谷歌地图(计算距离)
我们目前使用代理的配置脚本。
在我的应用程序中,我使用该方法查询file_get_contents Google Map。
$url = 'http://maps.google.com/maps/api/directions/xml?language=fr&origin='.$adresse1.'&destination='.$adresse2.'&sensor=false';;
$xml=file_get_contents($url);
$root = simplexml_load_string($xml);
$distance=$root->route->leg->distance->value;
$duree=$root->route->leg->duration->value;
$etapes=$root->route->leg->step;
return array(
'distanceEnMetres'=>$distance,
'dureeEnSecondes'=>$duree,
'etapes'=>$etapes,
'adresseDepart'=>$root->route->leg->start_address,
'adresseArrivee'=>$root->route->leg->end_address
);
}
但是使用代理我有一个未知的主机错误。 (我测试了我的家,代码工作正常)。我想知道是否有办法考虑我在浏览网页时标识自己的代理?
【问题讨论】:
标签: php proxy file-get-contents