php-general Digest 6 Dec 2011 17:21:42 -0000 Issue 7599

Topics (messages 315935 through 315941):

Webcal and file_get_contents
        315935 by: Davo Smith
        315936 by: Stuart Dallas
        315937 by: Davo Smith
        315938 by: Stuart Dallas
        315939 by: Stuart Dallas
        315940 by: Davo Smith
        315941 by: Jim Lucas

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Does anyone know if there is a simple way to convince
'file_get_contents' to treat webcal urls (e.g.
webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
being the same as an http url? (according to Wikipedia, http is
assumed for webcal urls)

I've looked into using 'stream_wrapper_register', but, unless I've
misunderstood it, this would require me to write the whole http access
myself, without being able to just pass it onto the internal http
processing code.

I've done some web searching, looked through the PHP docs and had a
look through the archives here, but not managed to find anything
(sorry if I've missed anything obvious).

Davo

--- End Message ---
--- Begin Message ---
On 6 Dec 2011, at 10:57, Davo Smith wrote:

> Does anyone know if there is a simple way to convince
> 'file_get_contents' to treat webcal urls (e.g.
> webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
> being the same as an http url? (according to Wikipedia, http is
> assumed for webcal urls)
> 
> I've looked into using 'stream_wrapper_register', but, unless I've
> misunderstood it, this would require me to write the whole http access
> myself, without being able to just pass it onto the internal http
> processing code.
> 
> I've done some web searching, looked through the PHP docs and had a
> look through the archives here, but not managed to find anything
> (sorry if I've missed anything obvious).


$url = str_ireplace('webcal://', 'http://', $url);

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
On Tue, Dec 6, 2011 at 11:01 AM, Stuart Dallas <stu...@3ft9.com> wrote:
> On 6 Dec 2011, at 10:57, Davo Smith wrote:
>
>> Does anyone know if there is a simple way to convince
>> 'file_get_contents' to treat webcal urls (e.g.
>> webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
>> being the same as an http url? (according to Wikipedia, http is
>> assumed for webcal urls)
>>
>> I've looked into using 'stream_wrapper_register', but, unless I've
>> misunderstood it, this would require me to write the whole http access
>> myself, without being able to just pass it onto the internal http
>> processing code.
>>
>> I've done some web searching, looked through the PHP docs and had a
>> look through the archives here, but not managed to find anything
>> (sorry if I've missed anything obvious).
>
>
> $url = str_ireplace('webcal://', 'http://', $url);

Thanks for the suggestion, but I've already tried that - the server
I'm connecting to expects the URL to start with 'webcal://', I'm
trying to find a way to get PHP to treat it as a http connection,
without changing the URL.

Davo

--- End Message ---
--- Begin Message ---
On 6 Dec 2011, at 11:05, Davo Smith wrote:

> On Tue, Dec 6, 2011 at 11:01 AM, Stuart Dallas <stu...@3ft9.com> wrote:
>> On 6 Dec 2011, at 10:57, Davo Smith wrote:
>> 
>>> Does anyone know if there is a simple way to convince
>>> 'file_get_contents' to treat webcal urls (e.g.
>>> webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
>>> being the same as an http url? (according to Wikipedia, http is
>>> assumed for webcal urls)
>>> 
>>> I've looked into using 'stream_wrapper_register', but, unless I've
>>> misunderstood it, this would require me to write the whole http access
>>> myself, without being able to just pass it onto the internal http
>>> processing code.
>>> 
>>> I've done some web searching, looked through the PHP docs and had a
>>> look through the archives here, but not managed to find anything
>>> (sorry if I've missed anything obvious).
>> 
>> 
>> $url = str_ireplace('webcal://', 'http://', $url);
> 
> Thanks for the suggestion, but I've already tried that - the server
> I'm connecting to expects the URL to start with 'webcal://', I'm
> trying to find a way to get PHP to treat it as a http connection,
> without changing the URL.

Create a stream context and use it to set the Host header to the webcal URL and 
pass that to file_get_contents with the HTTP URL.

http://php.net/stream_context_create

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
On 6 Dec 2011, at 11:05, Davo Smith wrote:

> On Tue, Dec 6, 2011 at 11:01 AM, Stuart Dallas <stu...@3ft9.com> wrote:
>> On 6 Dec 2011, at 10:57, Davo Smith wrote:
>> 
>>> Does anyone know if there is a simple way to convince
>>> 'file_get_contents' to treat webcal urls (e.g.
>>> webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
>>> being the same as an http url? (according to Wikipedia, http is
>>> assumed for webcal urls)
>>> 
>>> I've looked into using 'stream_wrapper_register', but, unless I've
>>> misunderstood it, this would require me to write the whole http access
>>> myself, without being able to just pass it onto the internal http
>>> processing code.
>>> 
>>> I've done some web searching, looked through the PHP docs and had a
>>> look through the archives here, but not managed to find anything
>>> (sorry if I've missed anything obvious).
>> 
>> 
>> $url = str_ireplace('webcal://', 'http://', $url);
> 
> Thanks for the suggestion, but I've already tried that - the server
> I'm connecting to expects the URL to start with 'webcal://', I'm
> trying to find a way to get PHP to treat it as a http connection,
> without changing the URL.

Create a stream context and use it to set the Host header to the webcal URL and 
pass that to file_get_contents with the HTTP URL.

http://php.net/stream_context_create

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
On Tue, Dec 6, 2011 at 11:14 AM, Stuart Dallas <stu...@3ft9.com> wrote:
> On 6 Dec 2011, at 11:05, Davo Smith wrote:
>
>> On Tue, Dec 6, 2011 at 11:01 AM, Stuart Dallas <stu...@3ft9.com> wrote:
>>> On 6 Dec 2011, at 10:57, Davo Smith wrote:
>>>
>>>> Does anyone know if there is a simple way to convince
>>>> 'file_get_contents' to treat webcal urls (e.g.
>>>> webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
>>>> being the same as an http url? (according to Wikipedia, http is
>>>> assumed for webcal urls)
>>>>
>>>> I've looked into using 'stream_wrapper_register', but, unless I've
>>>> misunderstood it, this would require me to write the whole http access
>>>> myself, without being able to just pass it onto the internal http
>>>> processing code.
>>>>
>>>> I've done some web searching, looked through the PHP docs and had a
>>>> look through the archives here, but not managed to find anything
>>>> (sorry if I've missed anything obvious).
>>>
>>>
>>> $url = str_ireplace('webcal://', 'http://', $url);
>>
>> Thanks for the suggestion, but I've already tried that - the server
>> I'm connecting to expects the URL to start with 'webcal://', I'm
>> trying to find a way to get PHP to treat it as a http connection,
>> without changing the URL.
>
> Create a stream context and use it to set the Host header to the webcal URL 
> and pass that to file_get_contents with the HTTP URL.
>
> http://php.net/stream_context_create

Thanks for your help - much appreciated.

Davo

--- End Message ---
--- Begin Message ---
On 12/6/2011 2:57 AM, Davo Smith wrote:
> Does anyone know if there is a simple way to convince
> 'file_get_contents' to treat webcal urls (e.g.
> webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
> being the same as an http url? (according to Wikipedia, http is
> assumed for webcal urls)

Reading the other emails makes me ask the question, must you use
file_get_contents?  Or could you use cURL?

> 
> I've looked into using 'stream_wrapper_register', but, unless I've
> misunderstood it, this would require me to write the whole http access
> myself, without being able to just pass it onto the internal http
> processing code.
> 
> I've done some web searching, looked through the PHP docs and had a
> look through the archives here, but not managed to find anything
> (sorry if I've missed anything obvious).
> 
> Davo
> 

-- 
Jim Lucas

--- End Message ---

Reply via email to