Bitcoin Forum
June 22, 2024, 04:23:47 AM *
News: Voting for pizza day contest
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Economy / Exchanges / Re: Official Liquid Exchange Thread on: November 06, 2018, 02:56:18 AM
hello admin,
Do you have any the examples of PHP  api placing an order

i use this code,but not work

Code:
<?php
 
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,
            ];
            
    
//&#12467;&#12531;&#12473;&#12488;&#12521;&#12463;&#12479;
    
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";
 
        
// &#27880;&#25991;&#12434;&#20986;&#12377;
        
$query_params = [

            
'order_type' => 'limit'// &#25351;&#12375;&#20516;:limit &#25104;&#12426;&#34892;&#12365;:market
            
'product_id' => $id,
            
'side' => $side// &#36023;&#12356;:buy &#22770;&#12426;: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_secrettrue);
        
$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($chCURLOPT_CUSTOMREQUEST'POST');
        
curl_setopt($chCURLOPT_POSTFIELDS$query_params);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_SSL_VERIFYPEERtrue);
        
curl_setopt($chCURLOPT_HTTPHEADER$header);
        
$response curl_exec($ch);
        
$json_decode json_decode($responsetrue);
        
curl_close($ch);
 
        return 
$json_decode;
    }
 
    private function 
base64url_encode($data) {
        return 
rtrim(strtr(base64_encode($data), '+/''-_'), '=');
    }
 
}
2  Economy / Service Discussion / do you have anyone use the btc-trade.com.ua on: August 17, 2018, 12:43:58 AM
Our company has four accounts, all of which cannot be logged in. Huh
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!