Subject: | Unicode Support Bug (SMS::MessageBird 0.03) |
Date: | Sat, 8 Dec 2018 02:00:35 -0800 |
To: | bug-SMS-MessageBird [...] rt.cpan.org |
From: | Kaitlyn Parkhurst <kparkhurst [...] intellisurvey.com> |
Hello,
I'm using SMS::MessageBird and have run into an issue with sending messages
with unicode.
I attempted to send the following message: "I am unicode 😁 !"
107 my $res = $sms->sms->send(
108 recipients => $message->phone_number,
109 body => "I am unicode 😁 !",
110 originator => $origin_number->phone_number,
111 datacoding => ( $type eq 'gsm' ? 'plain' : 'unicode' ),
112 );
I got the following error:
HTTP::Message content must be bytes at
/usr/share/perl5/vendor_perl/HTTP/Request/Common.pm line 94.
After some digging, I made the following patch for SMS/MessageBird/API.pm.
and it seems to have corrected the issue:
7a8
Show quoted text
> use Encode qw( encode_utf8 );
147,148c148,149
< $request_params{'Content-Type'} = 'application/json',
< $request_params{Content} = $content_payload;
---
Show quoted text> $request_params{'Content-Type'} =
'application/json;charset=utf-8',
Show quoted text> $request_params{Content} = encode_utf8($content_payload);
Thank you for your work on SMS::MessageBird, it's been wonderful to use.