我想使用 recurly 进行计费。我只有一个非常简单的示例,用于在我的indexController中进行测试:
public function init() {
require_once APPLICATION_PATH . '/../library/Recurly/recurly.php';
Recurly_Client::$apiKey = Zend_Registry::get('config')->get('recurly')->get('apikey');
Recurly_js::$privateKey = Zend_Registry::get('config')->get('recurly')->get('jskey');
Recurly_Client::$subdomain = 'mysubdomain';
}
我的recurlyAction:
public function recurlyAction(){
try{
$invoices = Recurly_InvoiceList::get();
foreach ($invoices as $invoice) {
print "Invoice: $invoice\n";
}
}
catch (Recurly_NotFoundError $e) {
print 'Record could not be found';
}
catch (Recurly_ValidationError $e) {
// If there are multiple errors, they are comma delimited:
$messages = explode(',', $e->getMessage());
print 'Validation problems: ' . implode("\n", $messages);
}
catch (Recurly_ServerError $e) {
print 'Problem communicating with Recurly';
}
catch (Exception $e) {
// You could use send these messages to a log for later analysis.
print get_class($e) . ': ' . $e->getMessage();
}
}
我正在尝试显示所有发票,仅用于测试。问题是我总是遇到这样的异常:
Recurly_ConnectionError:无法连接到 Recurly。
我已经在我的 Action 中使用 var_dump 检查了我的所有键,它们都正确显示。如您所见,我没有得到任何回应:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:4853
Content-Type:text/html
日期:Tue, 01 Oct 2013 06:54:36 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.2.22 (Debian )
Vary:Accept-Encoding
X-Powered-By:PHP/5.5.3-1~dotdeb.1
我正在使用一个流浪盒子,这可能是问题吗?有人可以帮我吗?我已经坚持了几天了...
更新:
有时我收到发票,有时没有...