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

curl-and-php

Capturing curl response output in variable from command line script

From: Ketema J. Harris <ketema_at_ketema.net>
Date: Tue, 22 May 2007 09:05:15 -0400

I have a simple script that behaves differently if I run it from
apache versus if i run it from the command line.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.some_script.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    print curl_error($ch);
} else {
    curl_close($ch);
}

echo "This is the response\n $response\n";

in apache the variable $response contains the html response from the
web page. on the command line this variable only contains a 1 and
the output is displayed on stdout. How can I cause the output to be
stored in the variable instead of being printed to stdout?

Thanks

Ketema J. Harris
www.ketema.net
ketema_at_ketema.net
ketemaj on iChat

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-05-22