qq_login.php 677 B

12345678910111213141516171819
  1. <?php
  2. require_once(PLUGINS_PATH .DIRECTORY_SEPARATOR. 'login'.DIRECTORY_SEPARATOR. 'qq'.DIRECTORY_SEPARATOR.'comm'.DIRECTORY_SEPARATOR."config.php");
  3. function qq_login($appid, $scope, $callback)
  4. {
  5. session('state',md5(uniqid(rand(), TRUE))); //CSRF protection
  6. $login_url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id="
  7. . $appid . "&redirect_uri=" . urlencode($callback)
  8. . "&state=" . session('state')
  9. . "&scope=".$scope;
  10. //halt($login_url);
  11. header("Location:$login_url");
  12. }
  13. //用户点击qq登录按钮调用此函数
  14. qq_login(session("appid"), session("scope"), session("callback"));
  15. ?>