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

curl-and-php

Re: Perl WWW::Curl::Easy equivalent of PHP's CURLOPT_RETURNTRANSFER

From: <admin_at_azuni.net>
Date: Fri, 20 Nov 2009 11:52:31 +0400

Daniel Stenberg wrote:

>> Can you please tell me how to use that?
>
> Well, I'm not a user of the perl binding but I looked at their package
> and it is strange that I can find them but you obviously can't:
>
> http://cpansearch.perl.org/src/SZBALINT/WWW-Curl-4.09/t/02callbacks.t
>
Thanks! Unit tests, coupled with official documentation, once again
prove to be the best howto on how to use the thing:

                my $response;
                 sub write_data($$$$) {
                         $response = shift;
                         return length($response);
                 }
                 $curl->setopt(CURLOPT_POSTFIELDS, $data);
                 $curl->setopt(CURLOPT_URL,
'https://example.com/path/to/script');
                 $curl->setopt(CURLOPT_VERBOSE, 1);
                 $curl->setopt(CURLOPT_POST, 1);
                 $curl->setopt(CURLOPT_SSLVERSION, 3);
                 $curl->setopt(CURLOPT_SSL_VERIFYPEER, 0);
                 $curl->setopt(CURLOPT_HEADER, 0);
                 $curl->setopt(CURLOPT_WRITEFUNCTION, \&write_data);
                 $curl->perform();
                 print STDERR "got response: '$response'\n";

Working like a charm without using any CURLOPT_WRITEDATA.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-11-20