Reputation: 3096
I'm using Perl to request some information (plain text) from a web service I built. When accessing using the browser, the info is shown perfectly. However, I'm new to handle responses using Perl. I do some database operations successfully, and my problem comes handling the response in Perl, not PHP.
How do I must encode or format the response in order to handle it successfully and output the same plain text in Perl?
EDIT:
Key points to take into consideration
My php script runs well
PHP code:
<?php
$this->layout = 'ajax';
$this->autoRender = false;
// Some database handling here with no problem...
echo "Plain text with info from database";
?>
Perl code:
#!/usr/local/bin/perl
require LWP::UserAgent;
require HTTP::Request;
my $request = HTTP::Request->new(GET => $url);
my $userAgent = LWP::UserAgent->new;
$userAgent->timeout(3);
$userAgent->env_proxy;
my $response = $userAgent->request($request);
if ($response->is_success) {
print "Success!\n";
#should print plain text AS IS
}
else {
print "something went wrong...\n";
die $response->status_line;
}
Upvotes: 1
Views: 522
Reputation: 118645
After checking $response->is_success
, you ought to be able to just take the return value of
$response->decoded_content
and process it however you see fit.
Upvotes: 1