WWW::OAuth::Util(3pm)

πŸ“¦
version 1.003 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– WWW::OAuth::Util πŸ’–

okay so bestie, this is the WWW::OAuth::Util(3pm) page from the User Contributed Perl Documentation, and it's literally just the lil toolbox of helper functions that WWW::OAuth uses. no cap, it's short and it's useful and we're gonna get through it together 🫢


✨ NAME ✨

WWW::OAuth::Util β€” utility functions for WWW::OAuth 🌸


πŸŽ€ SYNOPSIS πŸŽ€

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);

see how tidy that is?? chefs kiss πŸ‘‘


🌈 DESCRIPTION 🌈

WWW::OAuth::Util is the vibes-holder for utility functions made to be used with WWW::OAuth. and the best part: all functions are exportable on demand. you ask for them, you get them, no surprise imports sneaking into your namespace like an uninvited plus-one πŸ’…


πŸ¦‹ FUNCTIONS πŸ¦‹

πŸ“ form_urldecode

my $param_pairs = form_urldecode($body_string);

takes an "application/x-www-form-urlencoded" string and decodes it, handing you back an even-sized arrayref of key-value pairs. that's the whole glow-up.

and listen β€” two things it will not do to you:

  • Order is preserved πŸ”₯ (it doesn't reshuffle your params for fun)
  • Repeated keys are not combined πŸ’– (if bar shows up three times, bar shows up three times, periodt)

🧚 form_urlencode

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

this one flips it around: takes a hash or array reference and squishes it into an "application/x-www-form-urlencoded" string, perfect for a query string or a request body, whichever your little heart desires ✨

the deets:

  • if a value is an array reference, the key gets repeated once for each value. iconic behavior honestly
  • Order is preserved when you pass parameters in an array reference
  • when you pass a hash reference instead, the parameters get sorted by key for consistency β€” because hashes don't promise you order, bestie, and we're not gonna pretend they do 😭

πŸ‘‘ oauth_request

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 });

this is the main character function fr fr. it constructs an HTTP request container that performs the WWW::OAuth::Request role.

what you feed it:

  • a recognized request object, or
  • a hashref of arguments
  • ...optionally preceded by a container class name

and here's the cute little rule about that class name: if it does not contain "::", then it gets appended to "WWW::OAuth::Request::". so Basic becomes WWW::OAuth::Request::Basic, iykyk πŸ’…

what's currently recognized:

  • HTTP::Request objects βœ…
  • Mojo::Message::Request objects βœ…
  • hashrefs β€” these get used to construct a WWW::OAuth::Request::Basic object if no container class is specified

and if you wanna be extra explicit about it:

# 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 });

look at that. so thorough. so considerate. obsessed 😌


πŸ’€ BUGS πŸ’€

got a problem? report any issues on the public bugtracker. don't suffer in silence babes πŸ™ˆ


🌸 AUTHOR 🌸

Dan Book <dbook@cpan.org> β€” thank you for your service πŸ«‘πŸ’–


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

it's free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

slay, legally speaking ⭐


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page bestie!! πŸ¦‹ this was WWW::OAuth::Util as documented in perl v5.40.1, dated 2025-08-10 β€” go forth and urlencode responsibly, ily, bye πŸ’œβœ¨

πŸ“¦ where this page comes from