See post

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Digest::SHA qw(hmac_sha256_hex); use Time::HiRes qw(gettimeofday); use URI; use Encode; my $nonce = int (gettimeofday * 1000); my $url = "https://localbitcoins.com"; my $api_endpoint = "/api/merchant/new_invoice/"; my $hmac_key = "sdfsdfdsfdsfy"; my $hmac_secret = "sdfdsfdsf"; my %params = ( currency => 'USD', amount => '500', description => 'HEY', internal => '0', ); my $uri = URI->new(); $uri->query_form( \%params ); my $post_params_urlencoded = $uri->as_string; $post_params_urlencoded =~ s/^[?]//; my $message = encode('utf8',$nonce.$hmac_key.$api_endpoint.$post_param +s_urlencoded); my $signature = uc hmac_sha256_hex($message, $hmac_secret); my %headers = ( 'Apiauth-Key' => $hmac_key, 'Apiauth-Nonce' => $nonce, 'Apiauth-Signature' => $signature, ); my $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # remove exit to send request $ua->add_handler( request_prepare => sub { print "Request:\n".$_[0]->as_string; exit }); my $res = $ua->post( $url.$api_endpoint, %headers, Content => $post_pa +rams_urlencoded ); print "Content-type: text/plain\n\n"; if ($res->is_success) { print $res->content; } else { print $res->status_line; }
poj

In reply to Re^5: 500 Not a SCALAR reference by poj
in thread 500 Not a SCALAR reference by bigup401

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.