Do you have any the examples of PHP api placing an order
i use this code,but not work
class Quoine {
private $api_key = 'xxx';
private $api_secret = 'xxx';
private $pair = [
'btcjpy' => 5,
'ethjpy' => 29,
'bchjpy' => 41,
'dashjpy' => 44,
'qtumjpy' => 48,
'qashjpy' => 50,
'neojpy' => 54,
'xrpjpy' => 83,
];
//コンストラクタ
public function __construct() {
}
public function buyBtcLimit($price, $amount) {
$return = $this->buyLimit($this->pair["btcjpy"], $price, $amount);
return $return;
}
public function sellBtcLimit($price, $amount) {
$return = $this->sellLimit($this->pair["btcjpy"], $price, $amount);
return $return;
}
private function buyLimit($pair, $price, $amount) {
$return = $this->orderLimit('buy', $pair, $price, $amount);
return $return;
}
private function sellLimit($pair, $price, $amount) {
$return = $this->orderLimit('sell', $pair, $price, $amount);
return $return;
}
private function orderLimit($id, $side, $quantity, $price) {
$path = "/orders";
// 注文を出す
$query_params = [
'order_type' => 'limit', // 指し値:limit 成り行き:market
'product_id' => $id,
'side' => $side, // 買い:buy 売り:sell
'quantity' => $quantity,
'price' => $price
];
$nonce = microtime(true) * 1000;
$headers = ['alg'=>'HS256','typ'=>'JWT'];
$headers_encoded = $this->base64url_encode(json_encode($headers));
$payload = [
"path"=>$path,
"nonce"=>$nonce,
"token_id"=>$this->api_key
];
$payload_encoded = $this->base64url_encode(json_encode($payload));
$signature = hash_hmac("SHA256", "$headers_encoded.$payload_encoded", $this->api_secret, true);
$signature_encoded = $this->base64url_encode($signature);
$ch = curl_init('https://api.quoine.com'.$path);
$header = [
'Accept: application/json',
"X-Quoine-API-Version: 2",
"X-Quoine-Auth: " . "$headers_encoded.$payload_encoded.$signature_encoded",
'Content-Type: application/json',
];
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($ch);
$json_decode = json_decode($response, true);
curl_close($ch);
return $json_decode;
}
private function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
}