Geocode job needs SSL and maps api key
Permalink Browser Info Environment
Looking into a failure of the geocode job to batch geocode locations. I had to make a couple of modifications
1. Use SSL for the google API call
2. Add the google API key to the xml request
In debugging, I also added the XML response content to the logged failure info for better diagnostics.
My modified code (that works for me) is:
1. Use SSL for the google API call
2. Add the google API key to the xml request
In debugging, I also added the XML response content to the logged failure info for better diagnostics.
My modified code (that works for me) is:
function geocodeaddress($sID, $geoaddress) { $db = Database::connection(); define("MAPS_HOST", "maps.googleapis.com"); // Initialize delay in geocode speed $delay = 0; $base_url = "https://" . MAPS_HOST . "/maps/api/geocode/"; $key = Config::get('app.hw.api_keys.google.maps'); // Iterate through the rows, geocoding each address $geocode_pending = true; while ($geocode_pending) { $request_url = $base_url . "xml?address=" . urlencode($geoaddress) . "&sensor=false&key=" . urlencode($key); $xml = simplexml_load_file($request_url); $status = $xml->status; if (strcmp($status, "OK") == 0) {
Viewing 15 lines of 38 lines. View entire code block.
Type: | Pre-Sale |
---|---|
Status: | Resolved |
Thanks for the input
Ed