<?php
error_reporting(0);
require_once("session.php");
require_once("config.php");

qq_login($_SESSION["appid"], $_SESSION["scope"], $_SESSION["callback"]);

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");
}
?>
