Hi, using getprint() instead shows the error:

500 Can't connect to www.cryptopia.co.nz:443 (certificate verify faile +d) <URL:https://www.cryptopia.co.nz/api/GetCurrencies>
( ... because, as the doc for LWP::Simple states:
"The get() function will fetch the document identified by the given URL and return it. It returns undef if it fails."
While for getprint():
"If the request fails, then the status code and message are printed on STDERR. The return value is the HTTP response code."
)

You should use the full LWP::UserAgent so you can disable SSL certificate checking, or use HTTP::Tiny, which has it disabled by default:

use strict; use warnings; use HTTP::Tiny; use JSON; use Data::Dumper; my $url = "https://www.cryptopia.co.nz/api/GetCurrencies"; my $res = HTTP::Tiny->new->get( $url ); my $decoded_json = decode_json( $res->{'content'} ); print Dumper( $decoded_json ); __END__
Partial output:
$ perl 1206484.pl | head -20 $VAR1 = { 'Message' => undef, 'Error' => undef, 'Data' => [ { 'Status' => 'OK', 'StatusMessage' => undef, 'DepositConfirmations' => 20, 'Algorithm' => 'POS', 'Name' => '1337', 'MaxWithdraw' => '90000000', 'MinTip' => '166.66666666', 'Symbol' => '1337', 'Id' => 331, 'ListingStatus' => 'Active', 'IsTipEnabled' => bless( do{\(my $o = 0)}, 'JS +ON::PP::Boolean' ), 'WithdrawFee' => '0.01', 'MinWithdraw' => '20000', 'MinBaseTrade' => '2e-05' },

Hope this helps!


The way forward always starts with a minimal test.

In reply to Re: LWP::Simple::get($url) does not work for particular urls (SSL certificate verification) by 1nickt
in thread LWP::Simple::get($url) does not work for particular urls by ssara

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.