The essence of the question: There is a site that is registered through various services: yandex, mail, vk, facebook, etc. Https://ulogin.ru/ helps me with quick registration. So, I need to find out from which service a person comes in and apply certain actions as they are different actions for different services, get a user's avatar. In short, I need to get the user's avatar from the services (yandex, mail, vk, facebook, etc.).

  • 2
    But after all the code for authorization through these same services you have written. And that code knows exactly who and based on what it started up - Mike
  • I don’t think, authorization is using ulogin.ru - TotalHen
  • one
    Ok. Go to ulogin.ru. "Widget Settings" -> "User Information". there about the network through which he logged in something is written ... - Mike
  • It is. But how to get an avatar? - TotalHen
  • one
    See the service documentation. All the truth in the documentation - korytoff

1 answer 1

I did not work with the service, but both on the widget's receiving page and on the pages of its documentation, everything is indicated.

1) Correctly configure the widget ( https://ulogin.ru/help.php#fields ).

Because you need an avatar, you need to add the photo or photo_big key to the fields parameter of your widget. Accordingly, the code for insertion 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) Get the necessary data ( Documentation item 3 )

On your site, to the page where the service redirects, you need to process the data that came from the service, and request information about 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 independently implemented registration through these services (not cms with a plugin), then you should receive the token from the service and request user data from it ( Documentation item 4 ), respectively, you just need to add the key to the widget and you will see in the array the data you need.