区块链信息钱包支票支付员

2024-09-30 02:17:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建付款账单并通过电报发送给我的客户: 我正在使用区块链API V2-https://blockchain.info/api/api接收。我的代码是:

xpub='***'
keyk='02e57f1***'
url='https://api.blockchain.info/v2/receive?xpub='+str(xpub)+'&callback=https%3A%2F%2Fdoors03.ru&key='+keyk
x=requests.get(url)
r=x.json()
r=r['address']

是一个地址。 我要把它寄给我的客户(顺便问一下,有没有什么方法可以寄到确切的付款金额的地址)。我想查一下是否收到付款:

^{pr2}$

这是响应-u'{\n“message”:“内部处理程序错误”\n}' 我做错什么了?如何检查付款?如何发送地址和确切的btc或以太坊总和?在


Tags: httpsinfoapiurl客户地址区块电报
1条回答
网友
1楼 · 发布于 2024-09-30 02:17:03

Sorry, i don't have enough reputation to post a comment, so this is the only option i have. @egorkh have you solved this problem? Maybe you have received explanation from blockchain.info support? I have sent them a question about that, but they are answering for too long.

更新:最后,我找到了解决方案。在

在我的例子中,“Internal handlers error”消息的原因是对其API的错误解释。在

由于他们没有在他们的javaapi中实现balanceupdate请求,所以我是自己做的,而且我做得不对。在

我把这些参数:

{"key":keyk,"addr":r,"callback":"https%3A%2F%2Fdoors03.ru","onNotification":"KEEP", "op":"RECEIVE"}

作为post参数,就像在api中提供的其他方法一样。在这些方法中,参数是URLEncoded的,就像处理回调链接一样。但是。。。在

在这个HTML请求中,它们必须以json格式的纯文本形式发送,而不需要任何特殊编码,例如:

Map<String, String> params = new HashMap<String, String>();
    params.put("addr", address);
    params.put("callback", callbackUrl);
    params.put("key", apiCode);
    params.put("onNotification", keepOnNotification? "KEEP" : "DELETE");
    params.put("confs", Integer.toString(confirmationCount));
    params.put("op", StringUtils.isBlank(operationType) ? "ALL" : operationType);

//parse parameters map to json string(that's optional: you can write it  directly as string)
String body = new Gson().toJson(params);

if (requestMethod.equals("POST")) {
    byte[] postBytes = body.getBytes("UTF-8");
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type", "text/plain");
    conn.setRequestProperty("Content-Length", String.valueOf(postBytes.length));
    conn.getOutputStream().write(postBytes);
    conn.getOutputStream().close();
}

错误的主要原因可能是您将“Content-Type”:“text/plain”放在data object(,可能还有编码的回调url)中。在

相关问题 更多 >

    热门问题