Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » Event-Calendar-Module and CURL for webserver-proxy

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1604 Views
  • fischli
    Avatar
    Community Member
    7 Posts

    Event-Calendar-Module and CURL for webserver-proxy Link to this post

    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?

  • fischli
    Avatar
    Community Member
    7 Posts

    Re: Event-Calendar-Module and CURL for webserver-proxy Link to this post

    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?

  • web2works
    Avatar
    Community Member
    50 Posts

    Re: Event-Calendar-Module and CURL for webserver-proxy Link to this post

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

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

    1604 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.