2009-10-07 61 views
0

我試圖實現OpenID。我已經將我的代碼切回來嘗試讓OpenID工作(作爲一個消費者),但login()方法仍然失敗!這裏是代碼:Zend_OpenId_Consumer :: login()失敗

require 'Zend/Http/Client.php'; 
require 'Zend/OpenId/Consumer.php'; 

$client = new Zend_Http_Client(null, array(
    'adapter' => 'Zend_Http_Client_Adapter_Curl', 
)); 

$consumer = new Zend_OpenId_Consumer(); 
$consumer->setHttpClient($client); 

$url = 'https://www.google.com/accounts/o8/id'; 

$res = $consumer->login($url, 
         'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 
         '*'); 

echo '<pre>'; 
var_dump($res); 
echo '</pre>'; 

return; 

$ res,總是FALSE。

我使用的PHP 5.2.10,我有allow_url_fopen ON,cURL啓用和openssl啓用。我已經試過我的本地開發機器上的代碼和我的生產環境,並且下載工作!

任何人都可以指向正確的方向,我真的很難過這個!

感謝, 喬恩

回答

1

不要破解並且不要使用OpenID Enabled庫(如果你想堅持使用ZF)。

的Akeem的發展在這裏很好的解決方案:http://ak33m.com/?p=71&cpage=1

0

UPDATE:發現失敗here,因爲Zend_OpenId_Consumerdoesn't understand OpenID 2.0 (7.3) XRI由谷歌尚未提供。有關解決方法,請參閱How do I implement Direct Identity based OpenID authentication with Zend OpenID。 UPDATE END

嘗試打印$consumer->getError()而不是var_dump()。我得到一個

Discovery failed: HTTP Request failed: Error in cURL request: SSL certificate problem, verify that the CA cert is OK. Details: 
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 

這表明與驗證谷歌的SSL證書有關的問題。有幾種解決方案可用於此hereonSO

+0

我不明白像你捲曲的錯誤。奇怪的。我收到的只是「發現失敗:」沒有理由!我讀過你親切地張貼鏈接,因爲嘗試這樣修改: $配置=陣列( '銜接'=> 'Zend_Http_Client_Adapter_Curl', 'curloptions'=>陣列(CURLOPT_FOLLOWLOCATION =>真實, CURLOPT_SSL_VERIFYPEER = > false), ); $ client = new Zend_Http_Client(null,$ config); 但它仍然沒有工作,我仍然沒有得到一個有意義的錯誤信息! – Jon 2009-10-07 12:31:05

+0

查看我更新的問題和可能的解決方案。 – 2009-10-07 13:30:58

+0

完美的答案,謝謝你的清理。 Jon – Jon 2009-10-09 10:18:52