本文介绍了CoinKite new/receive - 传递正确的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Coinkite API 生成 new/receive 比特币公钥.问题是 API 拒绝了我的调用,并带有 Bad Request 的错误消息和一些针对强制参数的意外参数.

I am trying to generate a new/receive BitCoin pubkey with Coinkite API. The problem is that API rejects my call with an error message of Bad Request and some kind of unexpected arguments for the mandatory arguments.

$endpoint='/v1/new/receive';
$url='https://api.coinkite.com'.$endpoint;
$sign = CKsign($endpoint);

$API_KEY = 'KebXXXXXX-XXXXXXXX-XXXXXXXXXXXXXXXX';

$ch = curl_init($url);
curl_setopt($ch,CURLOPT_HTTPHEADER,array("X-CK-Key: {$API_KEY}", "X-CK-Sign: {$sign[0]}", "X-CK-Timestamp: {$sign[1]}"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
$data = array('memo' => 'test pubkey 1', 'account' => '1FXXXXXX-XXXXXX');
//$data = array(array("memo","test pubkey 1"), array("account","1F3A7E22A8-51F278"));
$data = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($ch);
curl_close($ch);

echo $result;

我得到的错误信息是:

{ "help_msg": "Unexpected arg(s): {\"memo\":\"test pubkey 
1\",\"account\":\"1FXXXXXX-XXXXXX\"}", "message": "Bad Request", "status": 
400 } 

被注释的行,虚拟向量,给出了同样的错误,我不明白为什么会发生这种情况,因为这些是强制性参数.我在这里做错了什么?

The line which is commented, the dummy vector, gives the same error and I don't understand why this is happening since these are mandatory arguments. What am I doing wrong here?

推荐答案

省略$data = json_encode($data);".在 https://github.com/coinkite/coinkite 找到解决方案-php/blob/master/lib/CKRequestor.php :$args = JSON 文档或参数数组".

Omit "$data = json_encode($data);". Found the solution in https://github.com/coinkite/coinkite-php/blob/master/lib/CKRequestor.php : "$args = JSON document or an array of arguments".

这篇关于CoinKite new/receive - 传递正确的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:58