I’m currently building a brochureware site based on my buddy‘s wordpress-come-CMS which he has dubbed “Redstart”. The beauty of building a site on top of wordpress‘ architecture is that all of the cool handy plugins that have been written for bloggers are now at your disposal!
So this particular site is calling for a google maps implimentation. Not that this is difficult by any stretch, but having a plugin pre-built to allow easy management from the wordpress console would be handy. Enter Phoogle. Phoogle allowed for next to instantaneous setup of a google maps implimentation. Simply provide it with an API key, make a few calls with the desired locations to map, and it does the rest. Worked beautifully.
The problem arose when I went to move to my staging server. I was receiving “file_get_contents” errors, with reference to my server configuration. Luckily, my host Dreamhost has a pretty handy wiki for these types of problems. This article turned up my solution:
$addressData = file_get_contents($apiURL.urlencode($address));
needed to be replaced by this convoluted piece of crud,
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $apiURL.urlencode($address));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$addressData = curl_exec ($ch);
/Note the added space between the function and the left parens. this will need to be removed in production/
Why, you might ask, well the wiki says the following:
In a measure to improve security, DreamHost has disabled the PHP option allow_url_fopen. This would normally allow a programmer to open, include or otherwise use a remote file using a URL, rather than a local file path. The cURL library provides a feature-rich alternative.
So it’s not totally pointless, but it does mean that the cURL solution (7 lines instead of 1) provides a more robust solution.
Hopefully this helps someone else.
[tags]wordpress, redstart, concept64, dreamhost, phoogle, gmaps, google maps, debugging[/tags]
Whatever you do, don't build your coworking community alone.
Join the 3000+ community builders who get my newest posts, lessons, stories, and tips like "How to fund your coworking space" and "Why I hate the title Community Manager"