【发布时间】:2014-04-20 14:26:00
【问题描述】:
这是我的 index.php 文件:
<?php
require 'openid.php';
try {
$openid = new LightOpenID('localhost');
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'http://steamcommunity.com/openid';
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Steam</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();
}
它的回声就出来了:
"User http://steamcommunity.com/id/**ID HERE OF USER WHO LOGGED IN**/ has/has not logged in."
所以我尝试回显 $openid->identity(); & validate() 在“用户 ------”之前,但它只会给我:
Fatal error: Call to undefined method LightOpenID::identity() in D:\wamp\www\index.php on line 19
如果我在“用户 ----------”之后执行此操作,它将打印出“http://steamcommunity.com/id/**/ has/has not logged in”。 所以我的问题是,我如何只打印出实际的 ID 而不是其余的?有人可以解释一下 -> 的东西,我相信它与 OOP 有关,但是你。
【问题讨论】: