DOKK / manpages / debian 12 / libwww-oauth-perl / WWW::OAuth::Util.3pm.en
WWW::OAuth::Util(3pm) User Contributed Perl Documentation WWW::OAuth::Util(3pm)

WWW::OAuth::Util - Utility functions for WWW::OAuth

 use WWW::OAuth::Util 'form_urldecode', 'form_urlencode';
 my $body_string = form_urlencode({foo => 'a b c', bar => [1, 2, 3]});
 # bar=1&bar=2&bar=3&foo=a+b+c
 my $ordered_pairs = form_urldecode($body_string);
 # ['bar', '1', 'bar', '2', 'bar', '3', 'foo', 'a b c']
 
 use WWW::OAuth::Util 'oauth_request';
 my $container = oauth_request($http_request);

WWW::OAuth::Util contains utility functions for use with WWW::OAuth. All functions are exportable on demand.

 my $param_pairs = form_urldecode($body_string);

Decodes an "application/x-www-form-urlencoded" string and returns an even-sized arrayref of key-value pairs. Order is preserved and repeated keys are not combined.

 my $body_string = form_urlencode([foo => 2, bar => 'baz', foo => 1]);
 # foo=2&bar=baz&foo=1
 my $body_string = form_urlencode({foo => [2, 1], bar => 'baz'});
 # bar=baz&foo=2&foo=1

Converts a hash or array reference into an "application/x-www-form-urlencoded" string suitable for a query string or request body. If a value is an array reference, the key is repeated with each value. Order is preserved if parameters are passed in an array reference; the parameters are sorted by key for consistency if passed in a hash reference.

 my $container = oauth_request($http_request);
 my $container = oauth_request({ method => 'GET', url => $url });
 my $container = oauth_request(Basic => { method => 'POST', url => $url, content => $content });

Constructs an HTTP request container performing the WWW::OAuth::Request role. The input should be a recognized request object or hashref of arguments optionally preceded by a container class name. The class name is appended to "WWW::OAuth::Request::" if it does not contain "::". Currently, HTTP::Request and Mojo::Message::Request objects are recognized, and hashrefs are used to construct a WWW::OAuth::Request::Basic object if no container class is specified.

 # Longer forms to construct WWW::OAuth::Request::HTTP_Request
 my $container = oauth_request(HTTP_Request => $http_request);
 my $container = oauth_request(HTTP_Request => { request => $http_request });

Report any issues on the public bugtracker.

Dan Book <dbook@cpan.org>

This software is Copyright (c) 2015 by Dan Book.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

URI, URL Living Standard <https://url.spec.whatwg.org/#application/x-www-form-urlencoded>

2022-12-06 perl v5.36.0