Website Access QQ Login

Source: Internet
Author: User
Tags openid

First introduce the authorization 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 access QQ Login


 The first to use the system comes with a button login, 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: the node ID of the Insert button, required Btnid: "QQLOGINBTN",//the user needs to confirm the scope authorization entry, optional, default all scope: "All",//Press 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 succeeded Console.log (Reqdata, opts);            Depending on the return data, replace the button display state method var dom = document.getElementById (opts[' Btnid '), _logouttemplate=[//Avatar ' <span></span> ',//nickname ' <span&gt ; {nickname}</span> ',//exit ' <span><a href= ' JAVASCRIPT:QC. Login.signout (); "       > Exit </a></span> '].join ' (""); Dom && (dom.innerhtml = QC. String.Format (_logouttemplate, {nickname:qc.   String.eschtml (Reqdata.nickname),//Do XSS filtering Figureurl:reqData.figureurl});   }, function (opts) {//Logout successful alert (' QQ login logout successful '); });Two, using the custom button <a> tag link past, and then after successful call this address, a tag of the href can refer to the first Window.locationQC.api ("Get_user_info", {})//Specify the interface to access the successful receive function,    s returns the response object for success. Success (function (s) {console.log (s); A successful callback to get OPENAPI's return Data alert ("Get user information successfully") via S.data  The current user nickname is: "+s.data.nickname); })//Specify the interface to access the failed receive function, and F returns the response object for failure. Error (function (f) {//Failure callback alert ("Get user information failed!  "); })//Specify the receive function after the interface completes the request, and C returns the response object for the completion request. Complete (function (c) {//Completion request callback alert ("Get user information complete!  "); });//check whether to log in if (QC. Login.check ()) {//If QC is logged in. Login.getme (OpenID, Accesstoken) {alert (["Current Logged on user", "OpenID:" +openid, "Accesstoken as:" +accesstoken].jo        In ("\ n"));        }); Here you can call your own save interface//...}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.