开发者

HTTP 500 error with Google Geocode Map

开发者 https://www.devze.com 2023-02-16 22:41 出处:网络
Here is my code: public function geocode($address){ $a = urlencode($address); $geocodeURL = \"http://maps.googleapis.com/maps/api/geocode/json?address=$a&sensor=false\";

Here is my code:

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);
     开发者_JAVA百科   if ($valid instanceof Frapi_Error) {
            return $valid;
        }

        $origin_address = $this->getParam('origin', self::TYPE_STRING));
        $this->geocode($origin_address);
    }

Why is it giving me a 500 HTTP error... is there some syntax that I am missing? Commenting the call to geocode removes this ERROR

Here's my error log:

2011/03/12 19:58:32 [error] 9966#0: *4555 FastCGI sent in stderr: "PHP Fatal error: Call to undefined function curl_init() in /var/www/api/src/frapi/custom/Action/Find_route.php on line 128" while reading response header from upstream, client: 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", host: "api.adasherasdasbang.me"


This means that cURL isn't installed on your system.

You probably just need to enable the module in your php.ini. See http://www.php.net/manual/en/curl.installation.php

0

精彩评论

暂无评论...
验证码 换一张
取 消