Posted in Javascript onMarch 09, 2021
qq登录很简单 先要去qq互联申请,通过后有key,然后是下面的代码
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="__PUBLIC__/index/layui/css/layui.css">
<script src="__PUBLIC__/index/layui/layui.js" type="text/javascript"></script>
<script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid="999999999" data-redirecturi="http://www.8m8.top/login/userqq.html" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript">
layui.use(['layer'], function(){
var layer = layui.layer,
$ = layui.jquery;
var is_login = QC.Login.check();
if(is_login){
var access_token = '999999999666666666';
var openid = '999999999';
QC.Login.getMe(function(openId, accessToken){
access_token = accessToken;
openid = openId;
});
var paras = {oauth_consumer_key:'999999999',access_token:access_token,openid:openid};
QC.api('get_user_info', paras).success(function(s){
//成功回调,通过s.data获取OpenAPI的返回数据
var param ={openid:openid,username:s.data.nickname,userhead:s.data.figureurl_qq_2,sex:s.data.gender};
//console.log(s);
$.post('{:url("login/loginqq")}',param,function(res){
if(res.code == 200){
QC.Login.signOut()//注销qq登陆
layer.msg(res.msg, {icon: 1, anim: 6, time: 1000},function(){
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
});
}else{
layer.msg(res.msg, {icon: 2, anim: 6, time: 1000});
}
});
//alert("获取用户信息成功!当前用户昵称为:"+s.data.nickname);
});
}else{
self.location.href='https://graph.qq.com/oauth2.0/authorize?client_id=999999999&response_type=token&scope=all&redirect_uri='+encodeURIComponent(self.location.href);
}
});
</script>
</body>
</html>
QQ登录简单实现代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@