Kernel::System::WebUserAgent - a web user agent lib
All web user agent functions.
create an object
use Kernel::System::WebUserAgent; my $WebUserAgentObject = Kernel::System::WebUserAgent->new( Timeout => 15, # optional, timeout Proxy => 'proxy.example.com', # optional, proxy );
return the content of requested URL.
Simple GET request:
my %Response = $WebUserAgentObject->Request( URL => 'http://example.com/somedata.xml', SkipSSLVerification => 1, # (optional) NoLog => 1, # (optional) );
Or a POST request; attributes can be a hashref like this:
my %Response = $WebUserAgentObject->Request( URL => 'http://example.com/someurl', Type => 'POST', Data => { Attribute1 => 'Value', Attribute2 => 'Value2' }, SkipSSLVerification => 1, # (optional) NoLog => 1, # (optional) );
alternatively, you can use an arrayref like this:
my %Response = $WebUserAgentObject->Request( URL => 'http://example.com/someurl', Type => 'POST', Data => [ Attribute => 'Value', Attribute => 'OtherValue' ], SkipSSLVerification => 1, # (optional) NoLog => 1, # (optional) );
returns
%Response = ( Status => '200 OK', # http status Content => $ContentRef, # content of requested URL );
You can even pass some headers
my %Response = $WebUserAgentObject->Request( URL => 'http://example.com/someurl', Type => 'POST', Data => [ Attribute => 'Value', Attribute => 'OtherValue' ], Header => { Authorization => 'Basic xxxx', Content_Type => 'text/json', }, SkipSSLVerification => 1, # (optional) NoLog => 1, # (optional) );
If you need to set credentials
my %Response = $WebUserAgentObject->Request( URL => 'http://example.com/someurl', Type => 'POST', Data => [ Attribute => 'Value', Attribute => 'OtherValue' ], Credentials => { User => 'otrs_user', Password => 'otrs_password', Realm => 'OTRS Unittests', Location => 'ftp.otrs.org:80', }, SkipSSLVerification => 1, # (optional) NoLog => 1, # (optional) );
This software is part of the OTRS project (https://otrs.org/).
This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.