0

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

jampez77
  • 5,012
  • 7
  • 32
  • 52

1 Answers1

0

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

mcont
  • 1,749
  • 1
  • 22
  • 33
  • thanks for replying, i've tried all your suggestions and i'm still getting the same error – jampez77 Aug 06 '13 at 20:03
  • Ok, rather than altering that values maybe it would be better to simply disable the cUrl option `FOLLOWLOCATION`. Try editing the file `/src/Geocaching/OAuth/OAuth.php` and changing the line 328 to `curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);`, then see if the script is working – mcont Aug 08 '13 at 15:19
  • with FOLLOWLOCATION set to FALSE I get: Fatal error: Uncaught exception 'Exception' with message 'couldn't connect to host' in. With FOLLOWLOCATION set to TRUE I get the same CURLOPT_FOLLOWLOCATION warning as before and the same error message... Fatal error: Uncaught exception 'Exception' with message 'couldn't connect to host' in – jampez77 Aug 09 '13 at 09:19