簡體   English   中英

Node.js區塊鏈比特幣API

[英]Node.js blockchain bitcoin api

所以我想用這個:(取自他們的API網站-> node.js文檔) https://github.com/blockchain/api-v1-client-node

收款: https : //github.com/blockchain/api-v1-client-node/blob/master/docs/Receive.md

var blockchain = require('blockchain.info');
var identifier = 'myidentifier'; 
var password = 'mypassword';
var myWallet = new blockchain.MyWallet(identifier, password);
var myBTCadress = '14Q3ufL1BUHtWskBKtsshVDATRY65TaJMB';

好的,所以接收部分:

var receive = new blockchain.Receive( [confirmations: 1], ? ); // What do I need to put here?

文檔說:callbackURL:回調應發送到的URL(字符串)

我不知道該輸入什么網址?

回調URL應該是重定向回您網站的URL。 因此,使用類似...的區塊鏈設置回調URL。

https://www.yoursite.com/callback/blockchain

假設您在應用中使用了express之類的方法,請按照以下步驟進行操作。

app.get('/callback/blockchain', function (req, res) {

// Stuff here  

});

您可能需要包括

var https = require('https'); 

這樣,您就可以在內部設置邏輯了……

// Stuff here
 var options = {
    host : 'api.blockchain.info',
    path : '/some/path/',
    port : 443,
    method : 'GET'
  }
 var request = https.request(options, function(response){
    var body = ""
    response.on('data', function(data) {
      body += data;
    });
    response.on('end', function() {
      res.send(JSON.parse(body));
    });
  });
  request.on('error', function(e) {
    console.log('Problem with request: ' + e.message);
  });
  request.end();

例如,這將在您將app.get('whateverurl')設置為任何頁面的json中輸出您請求的內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM