Converting the sample curl command to LWP::UserAgent using curl-to-lwp, I get the following:

#!perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new( 'send_te' => '0' ); my $r = HTTP::Request->new( 'POST' => 'https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messag +es.json', [ 'Accept' => '*/*', 'Authorization' => 'Basic JFRXSUxJT19BQ0NPVU5UX1NJRDokVFdJTElPX0FVVEhfVE9LRU4=' +, 'User-Agent' => 'curl/7.55.1', 'Content-Length' => '129', 'Content-Type' => 'application/x-www-form-urlencoded' ], "Body=This\x2520is\x2520the\x2520ship\x2520that\x2520made\x2520the\x25 +20Kessel\x2520Run\x2520in\x2520fourteen\x2520parsecs\x253F&From=\x252 +B15017122661&To=\x252B15558675310" ); my $res = $ua->request( $r, ); __END__ Created from curl command line curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUN +T_SID/Messages.json --data-urlencode "Body=This is the ship that mad +e the Kessel Run in fourteen parsecs?" --data-urlencode "From=+15017 +122661" --data-urlencode "To=+15558675310" -u $TWILIO_ACCOUNT_SID:$ +TWILIO_AUTH_TOKEN

If the above works, but your code does not, I'm not really sure where/how To goes missing...


In reply to Re: parsing curl api by Corion
in thread parsing curl api by frank1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.