curl-and-php
Re: Capturing curl response output in variable from command line script
Date: Tue, 22 May 2007 09:37:02 -0400
actually this wound up working for me:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
I stuck that option in there and the response was stored in the
variable.
Thanks!
On May 22, 2007, at 9:21 AM, haroon ahmad wrote:
> Hi
>
> I think it should work like this
>
> $response = shell_exec("php script.php");
>
> because the shell_exec will store whatever output it gets from the
> command line in $response variable.
>
> Regards,
> Haroon Ahmad
> Sr. Web Developer
> www.fastcreators.com
>
>
> On 5/22/07, Ketema J. Harris <ketema_at_ketema.net> wrote:
> 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
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-05-22