Hello!
I have been trying to figure out for several hours how to write authorization through popular services. Experience in programming is very little as well as knowledge, so please do not judge strictly.
Here, for example, I try through VC (id, key is correct):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>Аутентификация через ВКонтакте</title> </head> <body> <?php $client_id = '4928685'; // ID приложения $client_secret = 'cqOoHyEDg7wqBpSgnJWY'; // Защищённый ключ $redirect_uri = 'http://pblink.hol.es/'; // Адрес сайта $url = 'http://oauth.vk.com/authorize'; $params = array( 'client_id' => $client_id, 'redirect_uri' => $redirect_uri, 'response_type' => 'code' ); echo $link = '<p><a href="' . $url . '?' . urldecode(http_build_query($params)) . '">Аутентификация через ВКонтакте</a></p>'; if (isset($_GET['code'])) { $result = false; $params = array( 'client_id' => $client_id, 'client_secret' => $client_secret, 'code' => $_GET['code'], 'redirect_uri' => $redirect_uri ); $token = json_decode(file_get_contents('https://oauth.vk.com/access_token' . '?' . urldecode(http_build_query($params))), true); if (isset($token['access_token'])) { $params = array( 'uids' => $token['user_id'], 'fields' => 'uid,first_name,last_name,screen_name,sex,bdate,photo_big', 'access_token' => $token['access_token'] ); $userInfo = json_decode(file_get_contents('https://api.vk.com/method/users.get' . '?' . urldecode(http_build_query($params))), true); if (isset($userInfo['response'][0]['uid'])) { $userInfo = $userInfo['response'][0]; $result = true; } } if ($result) { echo "Социальный ID пользователя: " . $userInfo['uid'] . '<br />'; echo "Имя пользователя: " . $userInfo['first_name'] . '<br />'; echo "Ссылка на профиль пользователя: " . $userInfo['screen_name'] . '<br />'; echo "Пол пользователя: " . $userInfo['sex'] . '<br />'; echo "День Рождения: " . $userInfo['bdate'] . '<br />'; echo '<img src="' . $userInfo['photo_big'] . '" />'; echo "<br />"; } } ?> </body> </html> Wrong, error - http://pblink.hol.es/
From the materials in VC did not really understand. I would just id or get something in the js script or cookies. Help to understand and understand how to overcome these everyday difficulties.
Shl
Shoveling the Internet, I found a library on Node.js, but only immediately after trying to understand what Node.js is, I decided to look for another way. I also found the instruction http://ruseller.com/lessons.php?rub=37&id=1659 . On the local PC it works, on the server it does not.
After the evening trying to figure it out, ready to read instructions for morons, sorry until I found one. Ideally, you need a simple library that will work with google, vk, twitter. Widgets flip right away, because better write authorization that will be on the site.