Файл: vk/key.php
Строк: 27
<?php
session_start();
header("Content-type:text/html;charset=utf-8;");
include 'inc/vk_site.class.php';
$app_settings = "scope=notify,friends,photos,audio,video,docs,notes,pages,status,offers,questions,groups,notifications,stats,ads,offline";
$app_id = "3623455";
$app_redirect = "http://vkpr.ih/key.php";
$app_secret = "wYwPiKOCWDOM4IAqptbI";
if(isset($_GET['code'])){
$url = "https://api.vk.com/oauth/access_token?client_id=".$app_id."&client_secret=".$app_secret."&code=".$_GET['code']."&redirect_uri=".$app_redirect."";
$r = json_decode(file_get_contents($url));
$_SESSION['uid'] = $r->user_id;
$_SESSION['key'] = $r->access_token;
}
if(isset($_SESSION['uid'])){
$vk = new VK($_SESSION['key'],$_SESSION['uid']);
$user = $vk->usersGet($_SESSION['uid']);
echo "Hello, ".$user->response[0]->first_name;
}else{
echo "<br><br><br><a href='https://oauth.vk.com/authorize?client_id=".$app_id."&scope=".$app_settings."&redirect_uri=".$app_redirect."&response_type=code'>Авторизироваться</a>";
}
?>