我正在尝试使用new/receive
生成Coinkite API
BitCoin pubkey。问题是API拒绝我的调用,错误消息为Bad Request
,并且强制参数有某种意外的参数。
$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 }
被注释的行,虚拟向量,给出了相同的错误,我不明白为什么会发生这种情况,因为这些是强制性的参数。我在这里做错了什么?
答案 0 :(得分:1)
Omit" $ data = json_encode($ data);"。在https://github.com/coinkite/coinkite-php/blob/master/lib/CKRequestor.php:" $ args = JSON文档或参数数组"中找到了解决方案。
答案 1 :(得分:0)