S
S
sanya1642017-05-06 14:08:51
PHP
sanya164, 2017-05-06 14:08:51

How to set up uLogin authorization?

Added the simplest authorization code to the site through uLogin

<?php
session_start();

                    $s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
                    $user = json_decode($s, true);
                    //$user['network'] - соц. сеть, через которую авторизовался пользователь
                    //$user['identity'] - уникальная строка определяющая конкретного пользователя соц. сети
                    //$user['first_name'] - имя пользователя
                    //$user['last_name'] - фамилия пользователя
                    if (strlen($user['network']) > 0 )
                    {
                    	$_SESSION['auth_user'] = 'Авторизован';
                    }else {
                    	$_SESSION['auth_user'] = 'Не авторизован';
                    }

                    ?>

                    <p><?php echo $_SESSION['auth_user']; ?></p>
                    <p>Имя - <?php echo $user['first_name']; ?></p>                  

<script src="//ulogin.ru/js/ulogin.js"></script>
<div id="uLogin" data-ulogin="display=panel;theme=classic;fields=first_name,last_name;providers=vkontakte,odnoklassniki,mailru,facebook;hidden=other;redirect_uri=http%3A%2F%2Fsite.ru%2F;mobilebuttons=0;"></div>
6dc2424771024f0fb0a943591fdc62d8.PNG
In fact, the username should appear, but this does not happen, the page just refreshes

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question