我想反复使用结算。 我只是有一个非常简单的示例,用于在 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检查了所有键,它们都正确显示。我看不到任何回复:
缓存控制:无存储,无缓存,必须重新验证,后检查= 0,预检查= 0 连接:保持活动
内容编码:gzip
内容长度:4853
内容类型:text / html的
日期:星期二,2013年10月1日06:54:36 GMT
到期日:1981年11月19日星期四08:52:00格林尼治标准时间 保持活跃:超时= 5,最大= 100
附注:无缓存
服务器:Apache / 2.2.22(Debian)
有所不同:接受编码
X-已启动通过:PHP / 5.5.3-1〜dotdeb.1
我正在使用流浪盒,这可能是问题吗?任何人都可以帮我吗?我现在已经坚持了几天......
更新
有时我会收到发票,有时候不会......
答案 0 :(得分:2)
正如@karthikr所说,这听起来像是超时或网络问题。您是否可以在控制台上使用CURL来访问它?
答案 1 :(得分:2)
重新制作支持票并得到了这个答案:
您是否收到此类连接其他服务的错误?在client.php文件中,连接超时设置为10(这应该足够了)。你可以尝试调整它。
curl_setopt($ ch,CURLOPT_CONNECTTIMEOUT,10);
通常情况下,您不必编辑此内容,但我将其更改为30,现在工作正常..