Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include("vkapi.class.php");
- if($_GET["logout"]){$_SESSION[user_id]=null;}
- $appid="2773137"; $settings="photos"; $secret="<....>";
- $api=new vkapi($appid,$secret,$_SESSION["access_token"]);
- if($_GET["callback"]){
- $req=$_REQUEST["code"];
- $data=$api->token($req);
- if($data['access_token']){
- $_SESSION['access_token'] = $data['access_token'];
- $_SESSION['user_id'] = $data['user_id'];
- echo "<html><body onunload='window.opener.location.reload(true);'><script>window.opener.location.reload(true);window.close();</script></body></html>";
- exit();
- }
- }else{
- if($_SESSION["user_id"]!==null){$login=1;}else{$login=0;}
- }
- ?>
- <!DOCTYPE HTML5>
- <html>
- <head>
- <title> LogIn </title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script>
- var appID = "<?=$appid;?>";
- var settings = "<?=$settings;?>";
- var redirect = "http://local.lc/vk.php?callback=1";
- window.onload=function(){
- url='http://oauth.vkontakte.ru/authorize?client_id='+appID+'&scope='+settings+'&redirect_uri='+redirect+'& display=popup&response_type=code';
- }
- </script>
- </head>
- <body>
- <?php if($login==0){?>
- <button id="login" onClick='window.open(url,"vkauth", "location,width=620,height=320,top=0");'>Log in via VK.com</button>
- <?php }else{ ?>
- Hello, id<?=$_SESSION["user_id"];?>.<br />
- <?php } ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment