Hatena::ブログ(Diary)

satoru.netの自由帳 このページをアンテナに追加 RSSフィード

180112Friday

coincheck-API perl

#!/usr/bin/perl

use HTTP::Tiny;
use Digest::SHA qw/hmac_sha256_hex/;
use strict;

my $ACCESS_KEY = ACCESS_KEY;
my $SECRET_KEY = SECRET_KEY;

my $dt = time*10000;
my $url = "https://coincheck.com/api/ticker";
my $signature = hmac_sha256_hex($dt . $url ,$SECRET_KEY);
my $tiny = new HTTP::Tiny(
	default_headers => {
		"ACCESS-KEY" => $ACCESS_KEY,
		"ACCESS-NONCE"=> $dt,
		"ACCESS-SIGNATURE"=> $signature,
	}
);

my $res = $tiny->get("$url");
print $res->{content};

©satoru.net
Mail Twitter