【发布时间】:2016-10-11 16:22:19
【问题描述】:
我尝试在我的 cakePHP3 应用程序中使用 OpenID Steamauthentification 作为我的来源:https://github.com/SmItH197/SteamAuthentication
我制作了一个新的 Authenticate 组件,它工作正常,但我不得不添加一些代码行(标有 //+),这在我看来是没有意义的:
public function authenticate(Request $request, Response $response)
{
$openid = new \LightOpenID($steamauth['domainname']);
debug($openid);//+
if (!$openid->mode) {
$openid->identity = 'http://steamcommunity.com/openid';
header('Location: ' . $openid->authUrl());
$openid->authUrl();//+
debug($openid);//+
} elseif ($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if ($openid->validate()) {
$id = $openid->identity;
$ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
preg_match($ptn, $id, $matches);
debug($matches[1]);// steam id
return $matches;
} else {
return false;
}
}
return false;
}
因此,如果没有这 3 行,它将无法正常工作。 debug 正在返回变量本身,而 authUrl() 正在返回一个 Url 字符串。 有谁知道为什么我必须返回变量才能运行它?这可能是 PHP7 的问题吗?
相应的方法可以在githubrep文件steamauth.php中找到。
【问题讨论】:
标签: php cakephp openid cakephp-3.0