PHP geocaching API curl issues

447 views Asked by At

I'm trying to access user information using the Geocaching.com API service. Using the following script I get the errors mentioned below:

If i use it 'straight out of the box' (on a live server) i get back the following message:

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be         activated when safe_mode is enabled or an open_basedir is set in /home/mrmemeco/public_html/geo/src/Geocaching/OAuth/OAuth.php on line 329

Fatal error: Uncaught exception 'Exception' with message '28' in /home/mrmemeco/public_html/geo/src/Geocaching/OAuth/OAuth.php:334 Stack trace: #0 /home/mrmemeco/public_html/geo/src/Geocaching/OAuth/OAuth.php(206): Geocaching\OAuth\OAuth->curl_request('http://staging....') #1 /home/mrmemeco/public_html/geo/index.php(50): Geocaching\OAuth\OAuth->getRequestToken() #2 {main} thrown in /home/mrmemeco/public_html/geo/src/Geocaching/OAuth/OAuth.php on line 334

If i use it in the same way but on a localhost is get back HTTP error: 0 and no data is returned.

I've done a bit of googling and i have checked that safe mode is off but I've had no joy still.

It's definitely not my API keys as they work perfectly on the live demo

1

There are 1 answers

3
mcont On BEST ANSWER

You get that error because the configuration of your server doesn't allow cUrl to follow locations. There is more than one way to solve this:

  • If you have access to your server's root you have to edit the php.ini file and set safe_mode = false
  • Otherwise you can create an .htaccess file in the root of your site and put this inside php_value safe_mode off or...
  • You can change the value of safe_mode in your PHP script adding this line at the ini_set('safe_mode', false);

I hope it helps