Subject: | Missing support for POSTing parameters with multiple values |
Date: | Mon, 20 Jun 2016 18:32:04 +0000 |
To: | bug-WWW-Twilio-API [...] rt.cpan.org |
From: | Corey Maher <coreyamaher [...] gmail.com> |
The /2010-04-01/Accounts/{AccountSid}/Calls endpoint for creating new calls
supports multiple values for the StatusCallbackEvent parameter. These must
be encoded as StatusCallbackEvent=foo&StatusCallbackEvent=bar.
The current WWW::Twilio::API implementation only supports a single value
for each parameter.
Here's a simple patch that seems to work for me:
diff --git a/WWW/Twilio/API.pm b/WWW/Twilio/API.pm
index 1de309c..b1209aa 100644
--- a/WWW/Twilio/API.pm
+++ b/WWW/Twilio/API.pm
@@ -112,7 +112,10 @@ sub _build_content {
my @args = ();
for my $key ( keys %args ) {
$args{$key} = ( defined $args{$key} ? $args{$key} : '' );
- push @args, &$escape_method($key) . '=' .
&$escape_method($args{$key});
+ $args{$key} = [ $args{$key} ] unless (ref($args{$key}) eq 'ARRAY');
+ for (@{$args{$key}}) {
+ push @args, &$escape_method($key) . '=' . &$escape_method($_);
+ }
}
return join('&', @args) || '';