First to introduce the authorization JS file
<script type= "Text/javascript" src= "Http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" 101140406 "data-redirecturi=" http://127.0.0.1 "charset=" Utf-8 "></script>
Then access QQ Login
The first is to use the system's own button to log in, but this will pop up a new window, do not like//Call the Qc.login method, specify the Btnid parameter to bind the button in the container node QC. Login ({//btnid: Node ID for Insert button, required Btnid: "QQLOGINBTN",//user needs to confirm scope authorization, optional, default all scope: "All",//button size, available values [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 Success Console.log (Reqdata, opts); According to the returned data, the Replace button displays the state method var dom = document.getElementById (opts[' Btnid ')), _logouttemplate=[//Avatar ' <span></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),//XSS Filtering Figureurl:reqData.figureurl}));
}, function (opts) {//Logoff Success alert (' QQ login logout successful ');
}); The second, using a custom button <a> tag link to the past, and then successfully calling this address, a tag's href can refer to the first type of window.location Qc.api ("Get_user_info", {})//Specify interface access successful receive function , s for successful return responseObject. Success (function (s) {console.log (s); A successful callback is obtained by S.data to get the Openapi return Data alert ("Get the user information successfully!")
The current user nickname is: "+s.data.nickname"; //Specifies the receive function for interface access failure, F returns the response object for failure. Error (function (f) {//Failed callback alert ("Failed to get user information!")
"); //Specifies the receive function after the interface completes the request, and C returns the response object for the completion request. Complete (function (c) {//Complete request callback alert ("Get user information complete!")
");
}); Check if (QC) is logged in. Login.check ()) {//If the QC is logged in. Login.getme (OpenID, Accesstoken) {alert (["Current logged-on user", "OpenId is:" +openid, "Accesstoken is:" +accesstoken].join (
"\ n"));
}); Here you can call your own save interface//...}