我已经隔离了问题并找到了解决方法。该request()方法进行一些自动检测以找出如何建立 HTTP 连接:
protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
{
if (function_exists('curl_init')
&& (!in_array('https', stream_get_wrappers()) || !ini_get('safe_mode') && !ini_get('open_basedir'))
) {
return $this->request_curl($url, $method, $params, $update_claimed_id);
}
return $this->request_streams($url, $method, $params, $update_claimed_id);
}
在我的开发框中使用 CURL,但在我的 live 框中使用它file_get_contents()是因为检查失败。原因是open_basedir指令不为空。
如果我强制 LightOpenID 使用 CURL,一切都会顺利进行。
更新 #1: LightOpenID 在决定 curl 不可用时是正确的。我在日志文件中找到了这个:
启用安全模式或设置 open_basedir 时无法激活 CURLOPT_FOLLOWLOCATION
至于file_get_contents()版本,我怀疑我在库中发现了一个错字:
Index: lightopenid/openid.php
===================================================================
--- lightopenid/openid.php (0.60)
+++ lightopenid/openid.php (working copy)
@@ -349,7 +349,7 @@
$this->headers = $this->parse_header_array($http_response_header, $update_claimed_id);
}
- return file_get_contents($url, false, $context);
+ return $data;
}
protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
我已经通知了作者,他确认这是一个错误。如果它得到修复,我会报告。
更新 #2:该错误已于 2012 年 6 月在 master 分支中修复。它仍然不是稳定版本的一部分,但可以从代码存储库下载。