Add Google Business Hours to Joomla

I was wondering how to do this and never got it working till today. I wanted this in the footer of Joomla site running Gantry 5 template. Regular Labs Sourcer plugin was already installed. This will allow me to add some PHP in a Custom HTML module, and put the code in the footer position. Here was the code that was needed.

<?php
    $curlURL = 'https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ENTER_PLACE_ID_HERE';
    $curl = curl_init($curlURL);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1 );
    $response=curl_exec( $curl );
    for($i=0;$i<7;$i++){
        $day = jddayofweek($i,1);
        $start=stripos($response,'[\"'.$day.'\",')+strlen($day)+9;
        echo($day.": ".substr($response,$start,stripos($response,'\"]',$start)-$start)."<br />");
    }
?>

I got this from the following link:

https://webmasters.stackexchange.com/questions/103058/is-it-possible-to-show-the-hours-from-google-maps-on-a-website-so-that-the-webs

To get our Company business ID we used the following link.

https://developers.google.com/places/web-service/place-id

I typed in our business name, found our listing, and when I clicked on the red location arrow I got our business listing ID. Everything worked but the hours weren’t quite right. As I messed with it to get it right I suddenly started getting a different error.

302 Moved
The document has moved here.
Wednesday: http-equiv="content-type" content="text/html;charset=utf-8"> 

This error happens now due to too many requests. Going to give it some time to see if I can get it worked out from a different IP or wait a day or two.

After a couple of days I ended up putting a PHP file with the code above in the templates/hydrogen/html folder and using Sourcer plugin to “include” the code into a custom HTML module. This worked perfectly.

I hope this helps someone else out there…

0 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.