问题描述
我想生成一个新/接收
比特币PUBKEY与 Coinkite API
。问题是,API拒绝我的电话与无效请求的
的错误信息和一些意想不到的参数为强制性参数。
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;
该错误消息我得到的是:
The error message I get is:
{ "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?
推荐答案
省略$数据= json_en code($的数据);。找到了解决办法在:的$ 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新/接收 - 传递正确的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!