curl-library
Re: Re: Curl::easy / Authorize.net
Date: Wed, 23 Apr 2003 00:55:48 +0200 (CEST)
On Thu, 17 Apr 2003, Chris Ryan wrote:
> open BODY, ">body.out";
> $curl->setopt(CURLOPT_FILE,*BODY);
>
> my $body_called=0;
> my $chunk;
> my $auth_response;
> sub body_callback {
> my ($chunk,$handle)=@_;
> print STDERR "body callback called with ",length($chunk)," bytes\n";
> print STDERR "data=$chunk\n";
> $body_called++;
> return length($chunk); # OK
> }
You don't use the handle in the callback, and you don't store the data
anywhere?
> # test for ref to sub and body callback
> my $body_ref=\&body_callback;
> $curl->setopt(CURLOPT_WRITEFUNCTION, $body_ref);
>
> my $err_response = "";
> $auth_response = $body_ref;
$body_ref is a reference to a function, not any kind of result.
> As you might be able to tell, I'm trying to get the response into the var.
> $auth_response, but that is not what I get. With the above code, from the
> command line, this is what I get:
Well of course, you don't do anything useful with the data your callback
function receives
-- Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sfReceived on 2003-04-23