2012-08-14 131 views
3

我目前正在試驗實施一個openid爲大學的一個小網站。我對此很新,並跟進了相關文章。我已經下載了lightopenId並將該文件夾上傳到我的網絡服務器。我的學校有谷歌託管他們的電子郵件服務,所以典型的電子郵件地址是:像這樣[email protected]。我們可以登錄mail.google.com或專爲我們的登錄mail.google.com/a/oakland.edu/谷歌設計的自定義網頁。lightopenID for Google Google託管電子郵件

而不是讓用戶重定向到一般$openid->identity = 'https://www.google.com/accounts/o8/id';我可以讓用戶定向到自定義大學谷歌託管頁面進行身份驗證嗎?

給我的錯誤:

No OpenID Server found at http://mail.google.com/a/oakland.edu/accounts/o8/id

openid.php:

<? 
    <?php 
    require 'openid.php'; 
    try { 
     # Change 'localhost' to your domain name. 
     $openid = new LightOpenID('http://webprolearner.ueuo.com'); 
     if(!$openid->mode) { 
      if(isset($_GET['login'])) { 
       $openid->identity = 'mail.google.com/a/oakland.edu/accounts/o8/id'; 
       header('Location: ' . $openid->authUrl()); 
      } 
    ?> 
    <form action="?login" method="post"> 
     <button>Login with Google</button> 
    </form> 
    <?php 
     } elseif($openid->mode == 'cancel') { 
      echo 'User has canceled authentication!'; 
     } else { 
      echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.'; 
     } 
    } catch(ErrorException $e) { 
     echo $e->getMessage(); 
    } 

回答

2

據我所知,你的情況正確的身份是:

https://www.google.com/accounts/o8/site-xrds?hd=oakland.edu 

此網址返回一個有效的XRDS(所以LightOpenID將找到一個服務器)。

請注意,如果服務器配置不正確,則調用validate()時可能會出現類似錯誤。

+0

完美!這個效果很好! – techAddict82 2012-08-14 17:38:54

+0

哦,但是,我確實得到了:在http://oakland.edu/openid?id=103676657823296937874找不到OpenID Server。我現在能做什麼? – techAddict82 2012-08-14 17:51:45

+2

詢問能夠做到的人,在oakland.edu/openid返回xrds文檔,或者重定向到它。例如,通過包含以下代碼:'<?php header('X-XRDS-Location: https://www.google.com/accounts/o8/site-xrds?hd=oakland.edu'); ?>'。不幸的是,除非你想破解圖書館檢查「有效」網址(並打破openid規範),否則沒有其他辦法。 – Mewp 2012-08-14 19:42:07

相關問題