Answer the question
In order to leave comments, you need to log in
Authorization classmates?
I do authorization through classmates and it seems everything is not as easy there as it was with Vkontakte.
// Параметры приложения
$OAuth_OK = ['uid' => '123456789', 'key' => 'PUBKEY', 'secret' => 'SECRETKEY', 'redirect' => 'http://yadro/sign-ok',];
// Формируем ссылку для авторизации
$okparams = array(
'client_id' => $OAuth_OK['uid'],
'scope' => 'VALUABLE_ACCESS,LONG_ACCESS_TOKEN,GET_EMAIL',
'response_type' => 'token',
'redirect_uri' => $OAuth_OK['redirect']
);
// Получаем ссылку
echo '<a href="https://connect.ok.ru/oauth/authorize?'.urldecode(http_build_query($okparams)).'">Одноклассники</a>';
// После успешной авторизации получаем code
if(isset($_GET['code'])){
$params = array(
'client_id' => $clientId,
'client_secret' => $clientSecret,
'code' => $_GET['code'],
'redirect_uri' => $redirectUri
);
$content = file_get_contents('https://oauth.vk.com/access_token?' . urldecodehttp_build_query($params)));
$response = json_decode($content);
$token = $response -> access_token; // Токен
$expiresIn = $response -> expires_in; // Время жизни токена
$userId = $response -> user_id; // ID пользователя
$email = $response -> email; // EMAIL пользователя
$_SESSION['vkuid'] = $userId;
$_SESSION['token'] = $token;
$_SESSION['email'] = $email;
}
access_token=gdfsgdfsgsdfgsfg&session_secret_key=dsffasfasfa&expires_in=1800
Answer the question
In order to leave comments, you need to log in
For example, there are on the Internet. This is the first random example.
figured out in principle, there was only one question left:
I get a response of this type:
localhost/ok.php#access_token=1234567890&session_secret_key=1234567890&expires_in=1800
and I need to get:
localhost/ok.php?access_token=1234567890&session_secret_key=1234567890&expires_in=1800
? )))
---
With the first option, I naturally have no data, and with the second everything works, but changing every time during authorization is nonsense.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question