How can the website know what social network (postal) a man came into PHP?
-
Subject matter: There's a website that registers through different services: yandex, mail, vk, facebook, etc. Rapid registration helps https://ulogin.ru/ Now, I need to find out what service a man comes from and uses some kind of activity as different for different services, to get a user avatar. In brief, I have to get a user avatar from services.
-
I didn't work with the service, but it's all on the page of the viewing page and the pages of the documentation.
(1) That's right. https://ulogin.ru/help.php#fields )
You need avatar, you need a key. photo or photo_big parameter fields Your view. Accordingly, the supply code will be approximately as follows
<script src="//ulogin.ru/js/ulogin.js"></script> <div id="uLogin" data-ulogin="display=small;fields=first_name,last_name,photo_big,photo;providers=vkontakte,odnoklassniki,mailru,facebook;hidden=other;redirect_uri=http%3A%2F%2F"></div>
(2) To obtain the necessary data ( https://ulogin.ru/help.php#custom )
On your website, where the services are being redirected, it is necessary to process the data from the service and request information on the user:
$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['photo_big'] - большое фото //$user['photo'] - фото 100х100
If you were self-sustained to record through the service data (not cms with plastic), then you were supposed to get a token from the service and ask him for data on the user. https://ulogin.ru/help.php#custom You'll have enough to add the key to the view, and you'll see the data you need in the body.