in reply to Re^4: 500 Not a SCALAR reference
in thread 500 Not a SCALAR reference
See post
poj#!/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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: 500 Not a SCALAR reference
by bigup401 (Pilgrim) on Jan 08, 2019 at 09:11 UTC | |
by poj (Abbot) on Jan 08, 2019 at 09:44 UTC | |
by bigup401 (Pilgrim) on Jan 08, 2019 at 10:39 UTC | |
by poj (Abbot) on Jan 08, 2019 at 11:01 UTC |