First introduce authorized js file
<script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid="101140406" data-redirecturi="http://127.0.0.1" charset="utf-8"></script>
Then connect to QQ to log in
The first type uses the system's own button to log in, but this will pop up a new window. Don't like //Call the QC.Login method, specify the btnId parameter to bind the button to the container node QC.Login({ //btnId: the node id of the insert button, required btnId: "qqLoginBtn", //The scope authorization item that the user needs to confirm, optional, default all scope: "all", //Button size, available value [A_XL| A_L| A_M| A_S| B_M| B_S| C_S], optional, default B_S size: "B_M" }, function(reqData, opts){//Login successfully console.log(reqData, opts); //Replace the button display status method var dom = document.getElementById(opts['btnId']), _logoutTemplate=[ //Avatar'<span><img src="{figureurl}"/></span>', //Nickname'<span>{nickname}</span>', //Exit'<span><a href="javascript:QC.Login.signOut();" rel="external nofollow" >Exit</a></span>' ].join(""); dom && (dom.innerHTML = QC.String.format(_logoutTemplate, { nickname: QC.String.escHTML(reqData.nickname), //Do xss filter figureurl : reqData.figureurl })); }, function(opts){//Login successfully alert('QQ login successfully'); }); The second type is to use the custom button <a> tag to link it, and then call this address after success. The href of the a tag can refer to the first type of window.location QC.api("get_user_info", {}) //Specify the reception function of the interface to access successfully. s returns the Response object.success(function(s){ console.log(s); //Successful callback, obtain the return data of OpenAPI through s.data alert("Get user information successfully! The current user nickname: "+s.data.nickname); }) //Specify the reception function for failed interface access, f returns the Response object.Error(function(f){ //Failed callback alert("Get user information failed! "); }) //Specify the receiving function after the interface completes the request, c returns the Response object for the completion request.complete(function(c){ //Complete request callback alert("Get user information complete!"); }); //Check whether to log in if(QC.Login.check()){//If you have logged in QC.Login.getMe(function(openId, accessToken){ alert(["Current login user", "openId is: "+openId, "accessToken is: "+accessToken].join("/n")); }); //You can call your own save interface here//... }