Advertisement
hauruck

PHP wrapper for QUOINE API

Jan 9th, 2017
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2.        
  3.         // NOTE: NOT working, posted for support...
  4.  
  5. function quoine_get() {
  6.     // API settings
  7.     $auth_payload['path'] = '/crypto_accounts';
  8.     $auth_payload['nonce'] = (microtime(true)*10000);
  9.     $auth_payload['token_id'] = $this->apiKey;
  10.     $user_secret = $this->apiSec;
  11.  
  12.     $sign = JWT::encode($auth_payload, $user_secret, 'HS256');
  13.  
  14.     // generate the extra headers
  15.     $headers = array(
  16.       'X-Quoine-API-Version: 2',
  17.       'Content-Type: application/json',
  18.       'X-Quoine-Auth: '.$sign
  19.     );
  20.     // our curl handle (initialize if required)
  21.     static $ch = null;
  22.     if (is_null($ch)) {
  23.       $ch = curl_init();
  24.       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  25.     }
  26.     curl_setopt($ch, CURLOPT_URL, 'https://api.quoine.com/crypto_accounts');
  27.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  28.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  29.  
  30.     // run the query
  31.     $res = curl_exec($ch);
  32.  
  33.     if ($res === 'FALSE') throw new Exception('Could not get reply: '.curl_error($ch));
  34.     $dec = json_decode($res, true);
  35.     return $dec;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement