2017-09-04 1 views
0

Mon code extrait:comment configurer l'URL blockchain pour les opérations bitcoin? quelle sera l'URL de base pour les opérations blockchain url?

class Blockchain{ 
     protected $guid; // Blockchain wallet identifier (Wallet ID) 
     protected $api_code; // API code, required for creating wallets 
     protected $main_password; // Main Blockchain Wallet password 
     protected $second_password; // Second Blockchain Wallet password if double encryption is enabled 
     protected $port = 3000; // Blockchain Wallet service port 
     protected $base_url = 'http://127.0.0.1'; // Base url to connect to the Blockchain Wallet service 

     public function __construct($config) 
     { 
      // Set config values 
      $this->guid = $config['guid']; 
      $this->main_password = $config['main_password']; 
      // Optional ones 
      $this->api_code = (isset($config['api_code'])) ? $config['api_code'] : NULL; 
      $this->second_password = (isset($config['second_password'])) ? $config['second_password'] : NULL; 
      $this->base_url = (isset($config['base_url'])) ? $config['base_url'] : $this->base_url; 
      $this->port = (isset($config['port'])) ? $config['port'] : $this->port; 

      log_message('info', 'Blockchain Class Initialized'); 

      // Check if the Blockchain Wallet service is running 
      if ($this->execute($this->base_url.':'.$this->port) === NULL) { 
       show_error('Blockchain: Unable to connect to Blockchain Wallet service on: '.$this->base_url.':'.$this->port.''); 
       log_message('error', "Blockchain: Unable to connect to Blockchain Wallet service."); 
      } 
     } 

     public function wallet_balance() 
     { 
      // Get the base url 
      $url=$this->base_url; 

      // Add the port 
      $url.=':'.$this->port.'/'; 

      // Add the api url 
      $url.='merchant/'.$this->guid.'/balance'; 

      // Add options 
      // password 
      $url.='?password='.$this->main_password; 

      // Execute 
      return $this->execute($url); 
     } 

    public function execute($url) 
    { 
     // Get CURL resource 
     $curl = curl_init(); 
     // Set options 
     curl_setopt_array($curl, array(
      CURLOPT_RETURNTRANSFER => TRUE, 
      CURLOPT_URL => $url, 
      // CURLOPT_SSL_VERIFYPEER => FALSE, 
     )); 

     // Send the request & save response 
     $response = curl_exec($curl); 

     // Close request to clear up some resources 
     curl_close($curl); 

     log_message('debug', 'Blockchain: URL executed '.$url); 

     // Return the decoded response as an associative array 
     return json_decode($response, TRUE); 
    } 
} 

ce sera le base_url ..

je ne comprends pas la partie url de base ..

sera elle locale ou "https://api.blockchain.info" (comme ça)

exactement ce que je dois mentionner dans la déclaration suivante de code extrait ci-dessus:

protected $base_url = '???????????'; 

à partir de quel lien j'obtiendrai une réponse correcte?

Quelle est la procédure exacte pour se connecter avec blockchain ??

s'il vous plaît me préciser ce ..

+0

avez-vous la réponse, s'il vous plaît poster ici si vous avez ... merci –

Répondre

0

Je suis l'auteur de la bibliothèque Codeigniter-blockchain.

Le base_url est l'URL où il pointe vers le service de portefeuille Blockchain que vous avez installé, un guide complet pour installer le service peut être trouvé here. Vous devez avoir nodejs et npm installés.

Pour installer le Service Wallet Blockchain, exécutez la commande suivante:

npm install -g blockchain-wallet-service 

Maintenant, après l'installation, vous pouvez commencer avec cette commande:

blockchain-wallet-service start --port 3000 

3000 est le numéro de port, vous pouvez changez-le si vous le souhaitez.

maintenant à la bibliothèque:

protected $base_url = '???????????'; 

Cela devrait être réglé sur l'URL où le Service de portefeuille Blockchain est installé, dans ce cas localhost ou 127.0.0.1, qui est déjà défini par défaut.

protected $port = 3000; 

Ceci est le numéro de port où Blockchain Wallet Service est en cours d'exécution, cela devrait être le même port que vous avez utilisé lors du démarrage du service.