這裏是我的代碼:與谷歌的地理編碼地圖HTTP 500錯誤
public function geocode($address){
$a = urlencode($address);
$geocodeURL = "http://maps.googleapis.com/maps/api/geocode/json?address=$a&sensor=false";
$ch = curl_init($geocodeURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 200) {
$geocode = json_decode($result);
$lat = $geocode->results[0]->geometry->location->lat;
$lng = $geocode->results[0]->geometry->location->lng;
var_dump($lat);
var_dump($lng);
//return this->getClosest($lat, $lng);
} else {
$geo_status = "HTTP_FAIL_$httpCode";
//return -1;
}
}
public function executeGet()
{
global $my_neighbor_lists;
$valid = $this->hasRequiredParameters($this->requiredParams);
if ($valid instanceof Frapi_Error) {
return $valid;
}
$origin_address = $this->getParam('origin', self::TYPE_STRING));
$this->geocode($origin_address);
}
爲什麼給我一個500 HTTP錯誤......有一些語法,我很想念?談到調用地理編碼刪除此錯誤
這裏是我的錯誤日誌:
2011/03/12十九時58分32秒[錯誤] 9966#0:* 4555的FastCGI在標準錯誤發送:「PHP致命錯誤:在從上游讀取響應標頭時,調用未定義的函數curl_init()在第128行的「/var/www/api/src/frapi/custom/Action/Find_route.php」,同時從客戶端讀取響應標頭:70.176.18.156,server:api.frapi,request :「GET /route.printr?origin=1510%20E.%209th%20Street,%20Tucson,%20AZ & destination = 32%20North%20Campbell%20Avenue,%20Tucson,%20AZ HTTP/1.1」,upstream:「fastcgi: //127.0.0.1:9000「,主機:」api.adasherasdasbang.me「
您是否有權訪問錯誤日誌? – 2011-03-12 19:54:57
您請求哪個網址? – azat 2011-03-12 20:04:01
CURL似乎並未安裝在您的PHP中 – 2011-03-12 20:05:53