2017-09-04 12 views
0

私のコードスニペット:BASE_URLがどうなるか ビットコム操作用のブロックチェーンURLを設定する方法は?ブロックチェーンの操作URLのベース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); 
    } 
} 

...

私はベースURLの一部を理解していないです。..

意志それローカルまたは "https://api.blockchain.info"(このような)

上記のコードスニペットの次の文章で具体的に何を述べる必要がありますか。

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

どのリンクから私は正しい応答を得ますか?

ブロックチェインで接続するにはどうすればよいですか?

私にこれを明確にしてください。..

+0

答えがありましたら、ここに投稿してください......ありがとう –

答えて

0

を私はCodeigniter-blockchainライブラリの作者です。

base_urlは、インストールしたブロックチェーンウォレットサービスを指すURLです。サービスをインストールするための完全なガイドはhereです。

nodejsnpmがインストールされている必要があります。このコマンドを実行し、Blockchainウォレットサービスをインストールするには

npm install -g blockchain-wallet-service 

インストール後、次のコマンドでそれを起動することができます。

blockchain-wallet-service start --port 3000 

3000をすることができます、ポート番号ですあなたがしたい場合はそれを変更してください。今すぐ戻ってライブラリに

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

これはデフォルトですでに設定されている。この場合localhostまたは127.0.0.1、で、BlockchainウォレットサービスがインストールされているURLに設定する必要があります。

protected $port = 3000; 

これは、ブロックチェーンウォレットサービスが実行されているポート番号です。これは、サービスの開始時に使用したのと同じポートである必要があります。

関連する問題