how to send data to a URL?

how to send data to a URL?

am 01.06.2007 00:16:03 von gvidals

I'm writing an XML function that will listen for requests for data and
then respond with the data. Simple enough; however, the data needs to
be sent to the URL specified in the request. For example, the
resultant data may needed by www.123.com one time and www.abc.com
another time.

I use LWP all the time for requesting web pages, but can somebody
provide some guidance as to how LWP can be used to send data? I'm
confused.

Thanks!

Re: how to send data to a URL?

am 01.06.2007 03:25:28 von Andy

On May 31, 2007, at 5:16 PM, vidals wrote:

> I use LWP all the time for requesting web pages, but can somebody
> provide some guidance as to how LWP can be used to send data? I'm
> confused.

Use WWW::Mechanize, which is a wrapper around LWP and includes many
useful examples of POSTing data.

--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance

Re: how to send data to a URL?

am 01.06.2007 04:07:17 von tallwine

Andy Lester wrote:
>
> On May 31, 2007, at 5:16 PM, vidals wrote:
>
>> I use LWP all the time for requesting web pages, but can somebody
>> provide some guidance as to how LWP can be used to send data? I'm
>> confused.
>
> Use WWW::Mechanize, which is a wrapper around LWP and includes many
> useful examples of POSTing data.
>
>

Or if you like yours 'neat'

use LWP;
my $ua = LWP::UserAgent->new();
my $req = HTTP::Request->new(POST => 'http://fancywebservice.com');
my $xml = get_xml_data(); # your function here
my $length = length($xml);
$req->content($xml);
$req->header('Content-length' => $length);

my $res = $ua->request($req);
my $response_data = $res->content;

you might want to do a little more reading after this point.

-Tim