I’ve installed Phil Sturgeon’s REST module http://devot-ee.com/add-ons/rest/ which is now able to parse feeds. On my local (MAMP) install it works just fine but on my live site I keep hitting php errors. (what I’m trying to do is parse my Delicious feed - again on my local install this works fine)
On the live server I keep getting the following php errors when using it in an EE template: A PHP Error was encountered
Severity: Warning
Message: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
Filename: libraries/Curl.php
Line Number: 248and
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /www/pmh5232/public_html/system/expressionengine/third_party/rest/libraries/Curl.php:300)
Filename: core/Common.php
Line Number: 428The output of the template can be checked here: http://www.stookstudio.com/index.php/rest
Does anyone have any suggestions? I’ve already contacted Phil, he’s stumped too. Safe mode is off and open_basedir has a local value but no master value when I check the php info.
(admins: if this in the wrong forum then by all means move this).
open_basedir having a local value will trigger this error for you when you try to enable the CURLOPT_FOLLOWLOCATION option (this is what tells Curl to automatically follow any redirects it might receive). People using my Simple S3 Uploader add-on were also running into this issue. EngineHosting uses open_basedir so it is a fairly prevalent issue for many people using EE.
If you’re fairly certain that your API isn’t going to redirect you, you can safely disable this option. Here’s the code I used to conditionally enable this option in my add-on only for people not using open_basedir on their server:
if(!ini_get('open_basedir')) {
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
}Sure, please have a look at at the attached zip. Source_1 is the output with the original line 246 in pi.rest.php
if ( ! ini_get('safe_mode'))Source_2 is with the amended line 246
if ( ! ini_get('safe_mode') && ! ini_get('open_basedir'))My template code is just a basic:
<ul>
{exp:rest name="delicious"}
<li>{description}</li>
{/exp:rest}
</ul>With the amended line 246 it parses correctly but I’m still getting the basedir error: http://www.stookstudio.com/index.php/rest
e-man,
honestly, I dont’ consider that a good solution, as there are still errors, even if you are suppressing them. Without access to the code, I can’t say with certainty what the issue is, however the cURL option can’t be used over at EngineHosting, as openbase_dir for each user is set to their home directory. eg: /www/eh126xx I’d work with Phil to get the errors knocked out, and make sure your debug preference is set so you are able to see errors when you’re logged in. 😊
-greg
E-man,
I have the same issue. I exchanged a couple e-mails with Phil and now have everything working except I still get a warning:
“Severity: Warning
Message: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
Filename: libraries/Curl.php
Line Number: 248”
Is this why you turned off error reporting? How did you do this?
Thanks!
Guy
It seems I’m unable to use this module on EngineHosting at the moment. Has there been any progress on a fix or workaround? Any of my REST requests result in what seems like a forward to the REST request URL, instead of data being piped into the template. With error reporting on, I get:
A PHP Error was encountered Severity: Warning Message: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set Filename: libraries/Curl.php Line Number: 248
And
Fatal error: Call to undefined function json_decode() in /**********/expressionengine/third_party/rest/pi.rest.php on line 409
Seems like this open_basedir setting issue on EngineHosting keeps coming up again and again…
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.