我使用coinbase-php生成支付页面,并在我的网站上处理订单。我能够创建按钮和支付页面没有任何问题,但当我试图检查一个订单的状态,我得到一个401错误。我使用的代码是:
$coinbase = Coinbase::withApiKey($coinbase_key, $coinbase_secret);
$data = json_decode($coinbase->get('/orders/'.$order_id));这是相关的错误消息:
Notice: exception 'Coinbase_ApiException' with message 'Status code 401' in lib\Coinbase\Requestor.php:22
Stack trace:
#0 lib\Coinbase\Rpc.php(95): Coinbase_Requestor->doCurlRequest(Resource id #50)
#1 lib\Coinbase\Coinbase.php(64): Coinbase_Rpc->request('GET', '/orders/6c00ec5...', Array)
#2 inc\admin\orders.inc.php(214): Coinbase->get('/orders/N1263OA...') 我测试了库中的其他几个函数,createButton()似乎是唯一起作用的函数。
发布于 2014-04-03 18:18:29
我发现coinbase-php中包含了一个getOrder()函数,只是文档中没有它。此代码正在工作:
$coinbase = Coinbase::withApiKey($coinbase_key, $coinbase_secret);
$status = $coinbase->getOrder($order_id)->status;我仍然不清楚为什么我的原始代码失败,但至少我有一个解决方案。
发布于 2014-04-04 04:55:50
我知道你已经回答了你自己的问题,但让我来谈谈你为什么得到401错误。
正如@r3wt所提到的,401表示未经授权的错误。Coinbase最近引入了一个新特性,允许您管理任何api密钥对的权限。您可以在这里看到权限:http://i.imgur.com/ZKoGpz2.png
您的问题可能是由不正确的权限引起的。Coinbase也有一个中断,并更新了他们的API和UI。那时您可能已经进行了api调用,但它可能失败了。我希望这能解释你可能遇到的任何问题。
https://stackoverflow.com/questions/22829002
复制相似问题