qq号码网站源码分享,qq号大全

各位老铁们好,相信很多人对qq号码网站源码分享都不是特别的了解,因此呢,今天就来为大家分享下关于qq号码网站源码分享以及qq号大全的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!

1.1第三方登录

所谓的第三方登录,就是APP识别到用户将第三方的账号绑定到自己平台的ID上直接完成登录的过程,简单来说,是指基于用户在第三方平台上已有的账号和密码来快速完成己方应用的登录或者注册的功能。常见的第三方登录平台,一般是已经拥有大量用户的平台,国内的就是各大厂:微信、微博、QQ等,国外有Facebook、Twitter。

1.2扫码登录

现在的第三方平台基本都支持扫码登录,因为扫码登录更加安全,

而且不用记账号和密码

如:微信、qq、支付宝

2.QQ第三方登录

2.1qq互联

https://connect.qq.com/

2.2注册开发者

2.3文档

3.OAuth2.0介绍

3.1.QQ登录OAuth2.0总体处理流程

QQ登录OAuth2.0总体处理流程如下:

Step1:申请接入,获取appid和apikey;

Step2:开发应用,并设置协作者帐号进行测试联调;

Step3:放置QQ登录按钮;

Step4:通过用户登录验证和授权,获取AccessToken;

Step5:通过AccessToken获取用户的OpenID;

Step6:调用OpenAPI,来请求访问或修改用户授权的资源。

4.项目集成qq登录

4.1maven导入包

<!–QQ第三方登录–>

<dependency>

<groupId>net.gplatform</groupId>

<artifactId>Sdk4J</artifactId>

<version>2.0</version>

</dependency>

4.2.配置

最好查看qq给出的demo例子

创建qqconnectconfig.properties放在resources根目录下

app_ID=101543517

app_KEY=3d43255254a6f50876661fe2bec86684

redirect_URI=http://javatv.cn/loginAfter

scope=get_user_info,add_topic,add_one_blog,add_album,upload_pic,list_album,add_share,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idollist,add_idol,del_ido,get_tenpay_addr

baseURL=https://graph.qq.com/

getUserInfoURL=https://graph.qq.com/user/get_user_info

accessTokenURL=https://graph.qq.com/oauth2.0/token

authorizeURL=https://graph.qq.com/oauth2.0/authorize

getOpenIDURL=https://graph.qq.com/oauth2.0/me

addTopicURL=https://graph.qq.com/shuoshuo/add_topic

addBlogURL=https://graph.qq.com/blog/add_one_blog

addAlbumURL=https://graph.qq.com/photo/add_album

uploadPicURL=https://graph.qq.com/photo/upload_pic

listAlbumURL=https://graph.qq.com/photo/list_album

addShareURL=https://graph.qq.com/share/add_share

checkPageFansURL=https://graph.qq.com/user/check_page_fans

addTURL=https://graph.qq.com/t/add_t

addPicTURL=https://graph.qq.com/t/add_pic_t

delTURL=https://graph.qq.com/t/del_t

getWeiboUserInfoURL=https://graph.qq.com/user/get_info

getWeiboOtherUserInfoURL=https://graph.qq.com/user/get_other_info

getFansListURL=https://graph.qq.com/relation/get_fanslist

getIdolsListURL=https://graph.qq.com/relation/get_idollist

addIdolURL=https://graph.qq.com/relation/add_idol

delIdolURL=https://graph.qq.com/relation/del_idol

getTenpayAddrURL=https://graph.qq.com/cft_info/get_tenpay_addr

getRepostListURL=https://graph.qq.com/t/get_repost_list

version=2.0.0.0

4.3.建包oauth2并扫描

<context:component-scanbase-package=”cn.itsource.oauth2″/>

4.4.编写qqcontroller

\t@Controller\npublicclassQQController{\n@Autowired\nRestTemplaterestTemplate;\n\n@Autowired\nUserServiceuserService;\n\n//将页面重定向到qq第三方的登录页面\n@RequestMapping(value=”/qqLogin”)\npublicvoidqqLogin(HttpServletRequestrequest,HttpServletResponseresponse){\ntry{\nresponse.setContentType(“text/html;charset=utf-8″);\nresponse.sendRedirect(newOauth().getAuthorizeURL(request));//将页面重定向到qq第三方的登录页面\n}catch(Exceptione){\ne.printStackTrace();\n}\n}\n//登录之后回调地址\n@RequestMapping(value=”/loginAfter”)\npublicStringqqLoginAfter(HttpServletRequestrequest,HttpServletResponseresponse){\ntry{\nSystem.err.println(“============登录之后回调地址==========”);\nAccessTokenaccessTokenObj=(newOauth()).getAccessTokenByRequest(request);\nStringaccessToken=null,\nopenID=null;\nlongtokenExpireIn=0L;\nif(accessTokenObj.getAccessToken().equals(“”)){\n//我们的网站被CSRF攻击了或者用户取消了授权\nSystem.out.print(“没有获取到响应参数”);\n}else{\naccessToken=accessTokenObj.getAccessToken();\ntokenExpireIn=accessTokenObj.getExpireIn();\n//利用获取到的accessToken去获取当前用的openid——–start\nOpenIDopenIDObj=newOpenID(accessToken);\nopenID=openIDObj.getUserOpenID();\nSystem.err.println(“===============”+openID);\n//获取qq信息\nStringurl=”https://graph.qq.com/user/get_user_info?access_token=”\n+accessToken+”&oauth_consumer_key=101543517″+”&openid=”+openID+”&format=json”;\nStringjson=restTemplate.getForObject(url,String.class);\nObjectMapperobjectMapper=newObjectMapper();\nHashMapmap=objectMapper.readValue(json,HashMap.class);\nSystem.err.println(map);\nSystem.err.println(map.get(“figureurl_qq_1″));\n//如果用户表没有当前openid,那就添加用户,如果就有就直接跳转主界面main.jsp\\\nUseruser=newUser();\nuser.setQqOpenId(openID);\nUseru=userService.queryByParam(user);\nif(u!=null){\nSystem.out.println(u);\nreturn”main”;\n}else{\n//添加用户\nuser.setHeadImg((String)map.get(“figureurl_qq_1”));\nuser.setLoginName(UUID.randomUUID().toString());\nuser.setLoginPwd(“123456″);\nuserService.insert(user);\nreturn”main”;\n}\n}\n}catch(Exceptione){\ne.printStackTrace();\n}\nreturnnull;\n}\n}\n

4.5登录页面加入QQ登录

页面加入

绑定事件

4.6.修改hosts

C:\\Windows\\System32\\drivers\\etc

修改hosts文件,在末尾加入

127.0.0.1javatv.cn

好了,文章到这里就结束啦,如果本次分享的qq号码网站源码分享和qq号大全问题对您有所帮助,还望关注下本站哦!

Published by

风君子

独自遨游何稽首 揭天掀地慰生平