localbitcoin api instructions

Making requests to the API Most API requests need to be encoded with application/x-www-form-urlen +coded and sent as HTTP GET or POST requests to the appropriate API en +dpoint. When uploading files multipart/form-data encoding is also sup +ported. A total of three HTTP header fields are needed: Apiauth-Key HMAC authentication key that you got when you created your + HMAC authentication from the Apps dashboard. Apiauth-Nonce A unique number given with each API request. It's value +needs to be greater with each API request. Apiauth-Signature Your API request signed with your HMAC secret that y +ou got when you create your HMAC authentication from the Apps dashboa +rd. Apiauth-Nonce Each request also requires a nonce. A nonce is an integer number, that + needs to increase with every API request. It's value has to always b +e greater than the previous request. It is used to ensure identical A +PI requests have different signatures, making impossible for someone +to copy your API requests and re-execute them later on. A good trick to creating the nonce is to use the unix timestamp in mil +liseconds. This way you'll always get an incrementing number, just be + careful to not send two API calls at the same time or they will have + the same Nonce. Most API requests need to be encoded as application/x-www-form-urlenco +ded, when uploading files multipart/form-data encoding is also suppor +ted. With most programming languages you can urlencode your API reque +sts using standard functions. With Python you can use urllib.urlencode. Example: urllib.urlencode({" +foo":"bar", "baz": "quux"} which results in ?foo=bar&baz=quux. Apiauth-Signature The Apiauth-Signature is made by creating a string containing the foll +owing arguments and then hashing them with your HMAC authentication s +ecret using SHA256. The Nonce. A 63 bit positive integer, for example unix timestamp as mi +lliseconds. HMAC authentication key. API endpoint, for example, /api/wallet/. API arguments encoded as application/x-www-form-urlencoded. Files enco +ded as multipart/form-data.

am trying to run localbitcoin api, but just getting failure: 400

#!/usr/bin/perl -w BEGIN { print "Content-type: text/plain\n\n"; } use lib '.'; use HTTP::Tinyish; use Time::HiRes qw(time); my $url = "https://localbitcoins.com/api/merchant/new_invoice/"; my $headers = { Apiauth-Key => 'sdfsdf', Apiauth-Nonce => 'sdfsdf', Apiauth-Signature => 'sdfsdf', 'Content-Type' => 'application/x-www-form-urlencoded' }; my $content = ( currency => 'USD', amount => '500', description => 'hey', internal => '0', ); my $http = HTTP::Tinyish->new(); my $response = $http->post( $url => { content => $content, headers => $headers, }); if ($response->{success}) { my $output = $response->{content}; print "$output\n"; } else { print "failure: $response->{status}\n"; }

In reply to failure: 400 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.