forked from Moearly/YouBBS-EOEN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qqlogin.php
28 lines (23 loc) · 909 Bytes
/
qqlogin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
define('IN_SAESPOT', 1);
define('CURRENT_DIR', pathinfo(__FILE__, PATHINFO_DIRNAME));
include(CURRENT_DIR . '/config.php');
include(CURRENT_DIR . '/common.php');
error_reporting(0);
session_start();
$_SESSION["scope"] = $options['qq_scope'];
$_SESSION["appid"] = $options['qq_appid'];
$_SESSION["appkey"] = $options['qq_appkey'];
$_SESSION["callback"] = 'http://'.$_SERVER['HTTP_HOST'].'/qqcallback';
function qq_login($appid, $scope, $callback)
{
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
$login_url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id="
. $appid . "&redirect_uri=" . urlencode($callback)
. "&state=" . $_SESSION['state']
. "&scope=".$scope;
header("Location:$login_url");
}
//用户点击qq登录按钮调用此函数
qq_login($_SESSION["appid"], $_SESSION["scope"], $_SESSION["callback"]);
?>