Wordpress + Phoogle + Dreamhost, Problems and Solutions.

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:

The line

$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**/

curl_close($ch);

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: , , , , , , ,

No TweetBacks yet. (Be the first to Tweet this post)

Comments

8 Responses to “Wordpress + Phoogle + Dreamhost, Problems and Solutions.”

  1. WebDev Kungfu » Blog Archive » Using Phoogle with Wordpress (and Dreamhost) on January 27th, 2007 12:14 pm

    [...] Check out Alex’s blog post about Using Phoogle on Dreamhost  [...]

  2. Bruno on March 21st, 2007 12:04 pm

    Alex,

    I recently discovered Phoogle and it did save me some time, but as yourself, I also use Dreamhost as my test server and of course, came across the same file_get_contents problem.

    Just wanted to let you know that this solution came as a blessing after trying to resolve this issue in a different way.

    Keep up the good work :-)
    Thanks,
    Bruno.

  3. Josh on May 16th, 2007 4:21 pm

    Thank you so much for this. Worked perfectly!

  4. Seeker’s Jar :: Phoogle and GoDaddy: a work-around :: September :: 2007 on September 12th, 2007 10:58 pm

    [...] Eventually, after much wailing and gnashing of teeth, Google ‘fessed up this link to Alex Hillman’s Development blog, dangerouslyawesome. [...]

  5. Typolight on September 6th, 2008 10:39 am

    Thanks, you nice post that helped me alot.

  6. hot anime xxx girls on September 17th, 2008 3:47 am
  7. Jason on November 5th, 2008 10:12 pm

    Passed, senks author

  8. 2. cURL y su sintaxis URL « Tutorial CakePHP informal, sobre la marcha. ¡Participa! on December 18th, 2008 12:18 pm

    [...] y no puedo utilizar la función file_get_contents(). Pues bien, navegando por Internet descubrí este recurso que explica exactamente cómo se resuelve este problema: para que Phoogle funcione en un PHP [...]

Leave a Reply