本文整理汇总了PHP中PageModel::getUserBySteam方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::getUserBySteam方法的具体用法?PHP PageModel::getUserBySteam怎么用?PHP PageModel::getUserBySteam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::getUserBySteam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: steamAction
public function steamAction()
{
$model = new PageModel();
incFile('modules/page/system/inc/OpenId.inc.php');
$steamApi = "0426AC32C69FAF916BE374D15CA29B1D";
// новый ключ!!!
$openid = new LightOpenID(SITE_URL . 'page/steam');
if (!$openid->mode) {
$openid->identity = 'http://steamcommunity.com/openid/?l=english';
redirect($openid->authUrl());
} elseif ($openid->mode == 'cancel') {
$errorMessage = '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);
$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$steamApi}&steamids={$matches['1']}";
$json_object = file_get_contents($url);
$json_decoded = json_decode($json_object);
if ($json_decoded) {
$userData = $json_decoded->response->players[0];
if ($matches[1] == $userData->steamid && $userData->steamid) {
$isUser = $model->getUserBySteam($userData->steamid);
if ($isUser->id) {
setSession('user', $isUser->id, false);
redirect(url($isUser->id));
} else {
$errorMessage = 'Не прикреплен Steam аккаунт';
}
} else {
$errorMessage = 'Попробуйте еще раз позже';
}
} else {
$errorMessage = 'Попробуйте еще раз позже';
}
unset($json_object, $json_decoded);
} else {
$errorMessage = 'User is not logged in.';
}
}
setMyCookie('error', $errorMessage, time() + 5);
redirect(url());
}