According to cryptocapital v4 api release long time back but they don’t have any such php version of cryptocapital api. My team to make it simple built the v4 API for cryptocapital.

/**
 * Crypto Capital API v4
 * Deloloped by ITCS live / IndiaOnIt
 * author : ITCS Live
 */
class CryptoCapital
{
  private $_base_url = ‘https://api.cryptocapital.co/v4/‘;  // This is the V4 Api Url
  private $_api_key = null;  // You will get it from CryptoCapital website
  private $_api_secret = null; // You will get it from CryptoCapital website
  private $base_account_number = null; // You will get it from CryptoCapital website your Account Number
  public $nonce;
 This function is going to initiate the system with your own credential
  public function __construct($api_key, $api_secret, $base_url=NULL,$base_account_number)
  {
    date_default_timezone_set(‘UTC’);
    $this->_api_key = $api_key;
    $this->_api_secret = $api_secret;
    if (!is_null($base_url)) {
      $this->_base_url = $base_url;
    }
     if (!is_null($base_account_number)) {
      $this->base_account_number = $base_account_number;
    }
    $this->nonce = strtotime(‘now’).rand(10,9999);
  }
private function request($method, $message,$params) {
$whattodo_l = strtolower($method);
$whattodo_u = strtoupper($method);
$command = $whattodo_u;
$headers = array();
$signature = SHA1($message.$this->_api_key.$this->_api_secret);
$headers = array();
array_push($headers, ‘Content-Type:application/json’);
array_push($headers, “key:$this->_api_key”);
array_push($headers, “message:$message”);
array_push($headers, “signature:$signature”);
array_push($headers, “nonce:$this->nonce”);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_base_url.$method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if($whattodo_u==’TRANSFER’) {
curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$result = json_decode($response,true);
return $result;
  }
  /*the function for the ping the connection*/
   public function ping() {
    $command =”PING”;
    $message = $command .$this->nonce;
    $params=array();
   return $this->request(‘ping’, $message,$params);
  }
  /*this function is for the account statement*/
  public function AccountStatement($limit){
      $command =”STATEMENT”;
      $message = $command .$this->nonce.$this->base_account_number;
      $params=array();
   return $this->request(‘statement/’.$this->base_account_number.’?limit=’.$limit, $message,$params);
  }
  /*this function is used for the trnsfer money base account to another account
    @params
    trnsferToAc = the  account number where the amount goes
    currency =  iso 3 digit currency code in upper case (i.e USD,ERO,INR)
    amount =  float with 2 decimle places (i.e 15.00, 10.75)
    narration = the simple narration (i.e amount tfr for test account)
  */
  function AccountTransfer($trnsferToAc,$currency,$amount,$narration){
      $command =”TRANSFER”;
      $message = $command .$this->nonce.$this->base_account_number.$trnsferToAc;
      $params=json_encode ( array (
              “fromAccount” => $this->base_account_number,
              “toAccount” => $trnsferToAc,
              “currency” => $currency,
              “amount” => “$amount”,
              “narrative” => $narration
            ) );
   return $this->request(‘transfer’, $message,$params);
  }
  /*this function is for the get the account balance*/
  function getAccountBalannce(){
      $command =”ACCOUNT”;
      $message = $command .$this->nonce.$this->base_account_number;
      $params= array();
   return $this->request(‘account/’.$this->base_account_number, $message,$params);
}
  /*this function is used for create a new user for the account holder
  @params
  */
function createNewUser($email,$firstname,$lastname){
      $command =”USER”;
      $message = $command .$this->nonce;
      $params=json_encode ( array (
              “email” => $email,
              “firstname” => $firstname,
              “lastname” => $lastname,
              ) );
   return $this->request(‘user’, $message,$params);
}
/*This method is used to initiate an external transfer to another financial institution.
@params
$beneficiaryName = Name of the beneficiary account holder
$beneficiaryAccountNo = Account number of the beneficiary account
$beneficiaryBic = BIC string describing the beneficiary account (e.g. ABCDUSNYXXX)
$beneficiaryBank = Bank Name where the beneficiary account is held (e.g Bank of America)
$beneficiaryCountry =   2-character iso3166 country code of the bank (e.g. US)
$currency = iso 3 digit currency code in upper case (i.e USD,ERO,INR)
$amount = float with 2 decimle places (i.e 15.00, 10.75)
$narration =  Transfer narrative
*/
function withdrawAmount($beneficiaryName,$beneficiaryAccountNo,$beneficiaryBic,$beneficiaryBank,$beneficiaryCountry,$currency,$amount,$narration){
      $command =”WITHDRAW”;
      $message = $command .$this->nonce.$this->base_account_number.$beneficiaryAccountNo.$currency.$amount;
      $params=json_encode ( array (
              “fromAccount” => $this->base_account_number,
              “beneficiary” => array(
                    “name” => $beneficiaryName ,
                    “account” => $beneficiaryAccountNo ,
                    “bic” => $beneficiaryBic ,
                    “bank” => $beneficiaryBank ,
                    “country” => $beneficiaryCountry ,
                ),
              “currency” => $currency,
              “amount” => “$amount”,
              “narrative” => $narration
            ) );
   return $this->request(‘withdraw’, $message,$params);
}
// end of the class
}

For any Technical help Call Us today +91 983 689 2283

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *