in reply to Re: need to post a string without user intervention
in thread need to post a string without user intervention

Thank you Monks for pointing out a potential flaw (I wouldn't know) the endpoints were provided by the webservice and are correct. I have managed to cobble this bit together and the data is returned complete to the script so I can only guess this is correct. However the main issue is I get a 500 error after changing the code from this
if($response->code == 200) { print $response->as_string; }
to this
if($response->code == 200) { my $last=""; $last = $response->as_string; my $ua = LWP::UserAgent->new; my $action = 'http://www.booksforeducation.com/testbed/fred.php'; my $form = {xml => $last}; my $response = $ua->post($action, $form); }
So I guess the above script has no effect on the 500 internal server error. I am trying to post the result to another script (a php script) on the same server

Replies are listed 'Best First'.
Re^3: need to post a string without user intervention
by dpetrov (Acolyte) on Jun 03, 2009 at 07:39 UTC
    Okey dude. Let's say that you have your data in $last. Try smth like that:
    #!/usr/bin/perl -w use strict; use HTTP::Request::Common qw(POST); use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = POST 'http://www.booksforeducation.com/testbed/fred.php', [ +XML => $last, ]; my $response = $ua->request( $req )->as_string; print $resposne; # That's the output from your php script...
    If you want to print the response, as html at your web server, you should add at the top print "Content-type: text/html\n\n";