cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: getting a file

From: Steve Yeazel <stevey_at_frigidfluidco.com>
Date: Fri, 24 Jun 2005 00:45:20 -0500

On Thu, 23 Jun 2005 23:59:40 -0500, Daniel Kantor <dkantor_at_nyu.edu> wrote:

> I am trying to have curl retrieve a text file from a remote server,
> parse the text within that file, and then output it to the web browser.
> I cannot figure out how to parse the text though. Here is my code:
>
> <?php
>
> $ch = curl_init
> (“http://www.archive.org/download/jj2004-08-27/jj2004-08-27_vbr.m3u%e2%80%9d);
>
>
> curl_setopt ($ch, CURLOPT_FAILONERROR, true);
> curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
>
> $curl_exec = curl_exec($ch);
>
> curl_close ($ch);
>
> ?>
>
> Where exactly is the text to act upon? I tried some functions on $ch as
> well as $curl_exec and nothing worked.
>
> Thanks.
>
you have to use CURLOPT_URL and CURLOPT_RETURNTRANSFER (this will put the
data into a variable so you can parse it)

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"http://www.archive.org/download/jj2004-08-27/jj2004-08-27_vbr.m3u");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FAILONERROR, true);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);

$curl_exec = curl_exec($ch);
curl_close ($ch);

...do your processing on $curl_exec here...
?>
Received on 2005-06-24