Warning: file_get_contents error when loading Google Map

I am getting the following error when loading a map inside a popup at ciderweekny.com/locations (click on any link to load the popup):

Code:
Warning: file_get_contents(http://maps.google.com/maps/api/staticmap?center=41.74731,-74.08705099999997&zoom=14&size=375x325&maptype=roadmap&mobile=true&markers=41.74731,-74.08705099999997&sensor=false) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/cwnyttkkzz/ciderweekny.com/components/com_fabrik/helpers/image.php on line 274

Here is line 274:

PHP:
    // No cached image, grab image from remote URI and store locally
            file_put_contents($cacheFile, file_get_contents($src));


Here are the settings for the element being called:

cwmapelement.png



Here is the default_group.php file being called by the popup:

PHP:
<?php
/*
* This is where you will do your main template modifications.
*
*/
?>
 
<?php
/*
* This code sets up your first group.
*/
    reset($this->groups);
    $this->group = current($this->groups);
    $this->elements = $this->group->elements;
?>
 
<?php
/*
* Now we output the first group.  First a standard frameset, with id and
* style info.
*/
?>
 
    <fieldset class="fabrikGroup" id="group<?php echo $this->group->id;?>" style="<?php echo $this->group->css;?>">
    <legend><?php /*echo $this->group->title;*/?></legend>
 
    <?php if ($this->group->intro !== '') {?>
    <div class="groupintro"><?php echo $this->group->intro ?></div>
    <?php }?>
<?php
/*
* This is the meat of the customization, that allows you to place and
* format your elements on the page.  In this example, we're pretty much
* just duplicating the standard 'default' template layout, but doing it
* by placing each individual element, one by one.  You can get as creative
* as you want in your HTML formatting.
*
* The important thing is the two PHP lines for each element:
*
*    $this->element = $this->elements['short_element_name'];
*    echo $this->loadTemplate('element');
*
* ... which is what actually renders each individual element.  Note
* that this is one of the few places in Fabrik where you use the short
* element name (like 'first_name') instead of the full element name
* (like 'jos__fb_contact_sample___first_name').
*/
?>     
    <table style="width:900px;">
     
        <tr>
        <td VALIGN=TOP width="70%">
            <?php
            $this->element = $this->elements['establishmentname'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['establishmentaddressstreet'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['estabconcatenatecitystatezip'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['establishmentphone'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['establishmentwebsitelink'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['establishmenthours'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['establishmentdescription'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        <td VALIGN=TOP>
            <?php
            $this->element = $this->elements['establishmentmap'];
            echo $this->loadTemplate('element');
            ?>
            <?php
            $this->element = $this->elements['googlemaplink'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        </table> 
     
    </fieldset>
 
 
 
 
<?php
/* This must be the last thing that happens in this template.  It adds
* all hidden elements to the form, and also finds any non-hidden elements
* which haven't been displayed, and adds them as hidden elements (this
* prevents JavaScript errors where element handler code can't find the actual
* DOM structures for their elements)
*/
    /*echo $this->loadTemplate('group_hidden');*/
?>

The site was moved to a different server, but other than that, no changes made from when it was working.

J2.5.14
Fabrik 3.0.8
Any ideas?
 
The site was moved to a different server, but other than that, no changes made from when it was working.
Did you open/re-save your fabrik connection? Clear all Joomla cache?
 
most likely your server is set to not allow file_get_contents - if you can you should enable it, we use it and so does Joomla itself for things like updating components
 
file_get_contents is allowed on my server. Could this be a Google issue? I know gmail was down for part of the day yesterday.

I found this in a couple of related posts at stack overflow:

This error is occurs when allow_url_fopen is disabled. You'll need to use cURL to grab this file or change your PHP.ini config.


I checked to be sure allow_url_fopen is enabled; it is. Is there a way to use cURL to grab the file?
 
I still need help on this. I moved the site back to its development server where the maps were originally working. I checked the php settings and found:

allow_call_time_pass_reference On On
allow_url_fopen On On
allow_url_include Off Off

My understanding is that allow_url_fopen is what controls file_get_contents, and that is on. I am no longer getting the error message. Instead, I am getting the false.png returned instead of the map when going to http://ciderweekny.com/events and clicking on any of the events popups:

http://ciderweekny.com/cache/com_fa...1.2954713,-74.31465930000002.sensor=false.png

This problem seems to be intermittent. I can't figure out if it is cache related (cache is disabled in global config and caching plugins are turned off), Google API related or if it has something to do with Fabrik. Any advice is greatly appreciated.

J2.5.14
Fabrik 3.0.8

I found a similar problem in this post, but it is not clear what the resolution is: http://fabrikar.com/forums/index.php?threads/listview-static-google-maps-limit.34441/

Thanks.
 
We cache the files independent of Joomla's cache options.
The static map files seem ok to me, its name is composed of the map settings - so for example :
Code:
center=40.7358984,-73.9912281.zoom=12.size=375x325.maptype=roadmap.mobile=true.markers=40.7358984,-73.9912281.sensor=false.png
seens a valid file name.

Instead, I am getting the false.png returned instead of the map
Just checking but you are expecting to see a static image, and not the javascript map widget correct? If you need the interactive widget then set 'Use static map' to 'full'

That other post was what lead me to implement the caching in the first place, so I don't think its directly related to
 
Thanks, Rob. That was helpful.

Further research indicates that we are hitting the usage limits, as we are getting the map icon with red "x" on it as displayed under "Usage Limits" on this page: https://developers.google.com/maps/documentation/staticmaps/

My assumption is that Google tracks hits by URL, as I do not currently have an mapping API key. I saw that you added the ability to add a business key which is probably my next best option. Do you have any pointers or advice for dealing with this type of situation?
 
I think you've about summed it up. We already do whatever caching we can for the static maps, to keep your hit rate on Google down as much as we can. If you are exceeding their public rate limits, you'll need to use a Google business key.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top