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:
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) {

Type: Pre-Sale
Status: Resolved
JohntheFish
View Replies:
edbeeny replied on at Permalink Reply
edbeeny
Released a new version with the recommended code.
Thanks for the input

Ed

concrete5 Environment Information

8.4.3, php7.2

Browser User-Agent String

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.