Skip to content

Instantly share code, notes, and snippets.

@toshtech
Last active September 26, 2017 14:47
Show Gist options
  • Save toshtech/7aa5c560881aa2d8aea0713c7a4efe76 to your computer and use it in GitHub Desktop.
Save toshtech/7aa5c560881aa2d8aea0713c7a4efe76 to your computer and use it in GitHub Desktop.
BitFlyer APIを使用し建玉情報を取得します。
<?php
$fqdn = 'https://api.bitflyer.jp';
$path = '/v1/me/getpositions/?product_code=FX_BTC_JPY';
$url = $fqdn.$path;
$timeStamp = time();
$accessKey = 'アクセスキー';
$accessSecret = 'アクセスシークレット';
$message = $timeStamp."GET".$path.NULL;
$sign = hash_hmac("sha256", $message, $accessSecret);
$cl = curl_init();
$header = array(
"ACCESS-KEY:$accessKey\r\n".
"ACCESS-TIMESTAMP:$timeStamp\r\n".
"ACCESS-SIGN:$sign\r\n".
"Content-Type:application/json"
);
curl_setopt($cl, CURLOPT_HTTPHEADER, $header);
curl_setopt($cl, CURLOPT_URL, $url);
curl_setopt($cl, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($cl);
$array = json_decode($result, JSON_PRETTY_PRINT);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment