我正在使用 LightOpenID,虽然它很轻,但它不是很容易理解,而且它没有 wiki...
他们提供的示例文件如下(对不起,拉长的帖子),我不明白为什么它两次实例化 LightOpenID?
require 'openid.php';
try {
if(!isset($_GET['openid_mode'])) { // what is this about?
if(isset($_POST['openid_identifier'])) {
$openid = new LightOpenID;
$openid->identity = $_POST['openid_identifier'];
header('Location: ' . $openid->authUrl());
}
?>
<form action="" method="post">
OpenID: <input type="text" name="openid_identifier" /> <button>Submit</button>
</form>
<?php
} elseif($_GET['openid_mode'] == 'cancel') {
echo 'User has canceled authentication!';
} else {
$openid = new LightOpenID;
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
如果有人真的觉得有帮助,我会尝试将其添加到我现有的脚本中。我怎样才能做到当 $openid->validate() 返回 true 时,我可以将 $sql_answer 保存到数据库中?