Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Event-Calendar-Module and CURL for webserver-proxy


Reply


3 Posts   1740 Views

Avatar
fischli

Community Member, 7 Posts

10 June 2010 at 2:37am

I would like to fetch an iCal-calendar from external websites (Google, etc.) with the event_calendar_module. To do this I have to use proxy for url-requests from the SS. The iCal.php uses

$ical = file_get_contents($file);

and not the SimplePie-Framework to do this, right?
So I've replaced file_get_content($file) with a call of a function with curl_opts:

   function curl_get_file_contents($URL)
   {
    $c = curl_init($URL);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($c, CURLOPT_URL, $URL);
         curl_setopt($c, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
         curl_setopt($c, CURLOPT_PROXY, "proxy.webserver.com");
         curl_setopt($c, CURLOPT_PORT, 3128);
         curl_setopt($c, CURLOPT_PROXYUSERPWD, "user:password");
       $contents = curl_exec($c);
    curl_close($c);

if ($contents) return $contents;
else return FALSE;
   }

Unfortunately I don't have PHP-knowledges so I didn't have success at all: Call to undefined function curl_get_file_contents() :-(
What's the error in reasoning?

Avatar
fischli

Community Member, 7 Posts

30 July 2010 at 1:48am

Edited: 30/07/2010 6:37pm

Ok. So I push this forward because I need some PHP-based knowledge to solve this.
Simple question to the event_calendar module or anything other in PHP:

file_get_contents() doesn't work for me, because my webhoster limits outgoing traffic through proxy. So I have to use curl instead and I tried to replace the file_get_contents with the name of a new function and put the function in the iCal.php. But this causes an error "Fatal error: Call to undefined function curl_get_file_contents() in.../htdocs/event_calendar/code/iCal.php on line 27".
The curl_get_file_contents-function is working in an example script, but not in iCal.php. So I shifted this function in Calender.php without any better result.
What's wrong with my idea?

Avatar
web2works

Community Member, 50 Posts

27 May 2011 at 11:17pm

Late reply - you need PHP extension called PHP Curl installed and enabled

I simple install like this:
sudo port install php5-curl